spring-boot会自动扫描到starter项目下的META-INF/spring.factories的配置文件,其中
//自动配置
//org.springframework.boot.autoconfigure.EnableAutoConfiguration指向配置类
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.xxx.xxx.xxx
starter项目需要引入被自动配置的项目的坐标
通过配置类com.xxx.xxx.xxx注册bean
@Configuration//标记配置类
@EnableConfigurationProperties(xxxProperties.class)//关联一个属性类
在配置类中引入类xxxProperties的属性,xxxProperties中有类上注解设置前缀,如@ConfigurationProperties(prefix = "kuaidiniao")
用来给springboot项目外化配置,使用时kuaidiniao.xxx.xxx:xxx
在该bean里面给需要用到的实例进行配置 将XXXPropertis的属性值setter赋值给需要实例化的对象
springboot在读取到外化配置后会自动引入被自动配置的项目的坐标(传递依赖)
并且实例化bean