Skip to content

Commit

Permalink
starter模块
Browse files Browse the repository at this point in the history
  • Loading branch information
guolanren committed Apr 14, 2020
1 parent 0a35be4 commit 8c8da02
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 0 additions & 2 deletions email/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
<groupId>name.guolanren</groupId>
<artifactId>email</artifactId>
<version>1.0.0</version>
<name>email</name>
<description>spring email</description>

<properties>
<java.version>1.8</java.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package name.guolanren.autoconfigure;

import name.guolanren.service.BootStarterService;
import name.guolanren.service.StarterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -13,20 +14,21 @@
* @author guolanren
*/
@Configuration
@EnableConfigurationProperties(BootStarterProperties.class)
@ComponentScan("name.guolanren")
@EnableConfigurationProperties(StarterProperties.class)
@ConditionalOnExpression("true")
@Import({})
public class BootStarterAutoConfiguration {
public class StarterAutoConfiguration {

@Autowired
private BootStarterProperties bootStarterProperties;
private StarterProperties starterProperties;

@Bean
@ConditionalOnMissingBean(BootStarterService.class)
public BootStarterService bootStarterService() {
BootStarterService bootStarterService = new BootStarterService();
bootStarterService.setMsg(bootStarterProperties.getMsg());
return bootStarterService;
@ConditionalOnMissingBean(StarterService.class)
public StarterService bootStarterService() {
StarterService starterService = new StarterService();
starterService.setMsg(starterProperties.getMsg());
return starterService;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author guolanren
*/
@ConfigurationProperties(prefix = "boot.starter")
public class BootStarterProperties {
public class StarterProperties {

private String msg = "Hello Hell";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @author guolanren
*/
public class BootStarterService {
public class StarterService {

private String msg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"name": "boot.starter.msg",
"type": "java.lang.String",
"defaultValue": "Hello Hell",
"description": "this is msg description."
"description": "this is msg description...",
"sourceType": "name.guolanren.autoconfigure.StarterAutoConfiguration"
}
]
}
2 changes: 1 addition & 1 deletion starter/src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
name.guolanren.autoconfigure.BootStarterAutoConfiguration
name.guolanren.autoconfigure.StarterAutoConfiguration

0 comments on commit 8c8da02

Please sign in to comment.