一、如何自定义一个SpringBoot Starter
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
2.在resources文件夹下面新建文件夹:MATE-INF
,在新建的文件夹下面建立文件:spring.factories
@Configuration
public class MyStarterConfig {
@Bean
public SayHelloService getSayHelloService() {
return new DefaultSayHelloService();
}
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.sxli.mystarter.config.MyStarterConfig
mvn install:install-file -Dfile=F:\GitHub\my-starter\target\my-starter-1.0.jar -DgroupId=com.sxli -DartifactId=my-starter -Dversion=1.0 -Dpackaging=jar
二、验证自定义的SpringBoot Starter是否生效
<dependency>
<groupId>com.sxli</groupId>
<artifactId>my-starter</artifactId>
<version>1.0</version>
</dependency>
http://localhost:8080/mystarter/say