1. 首先需要引入maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
2. 编写AutoConfig
配置类
3. 添加spring.factories
文件
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.example2.autoconfig.MyAutoConfiguration
目录结构如下: