springboot 自定义start

 

 

七、验证自己写的启动器是否可用

(1)创建一个测试工程,勾选web工程

springboot 自定义start

 

(2)引入自己写的启动器

<!--引入自己的启动器-->
<dependency>
    <groupId>com.huang</groupId>
    <artifactId>hua-spring-boot-start</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

(3) 编写测试类,引用helloService

springboot 自定义start

springboot 自定义start




六、安装自动配置工程和启动器到本地maven

springboot 自定义start

 

springboot 自定义start




五、写自动配置类和其他类

 

springboot 自定义start

springboot 自定义start

springboot 自定义start

 




四、修改自动配置类

(1)去掉无用的配置文件和主程序启动类,使用start自动的配置类

springboot 自定义start

 

(2)去掉无用的依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>



三、start 启动器引入自动配置工程

 

springboot 自定义start

 

 





二、具体实现方法

 

(1)、创建一个空工程,内含1个启动类start用于依赖引入,1个自动配置项目

springboot 自定义start

(2)创建一个对外依赖的模块(对内引入其自动配置模块) 和 自动配置模块

springboot 自定义start

 

springboot 自定义start

 

springboot 自定义start

 

springboot 自定义start

 

 

 





一、自定义starter方法步骤:

springboot 自定义start

springboot 自定义start

 

即需要一个start用于对外的依赖,该工程具体功能是自动配置模块,即star引用该自动配置项目