Version: Next
自动装配原理
@SpringBootApplication
@SpringBootConfiguration
@Configuration
@EnableAutoConfiguration
@AutoConfigurationPackage
@Register -> componentScan扫到的包名,以全局变量的形式暴露
@AutoConfigurationImportSelector
getCandidateConfigure() 方法
- 里面是 SpringFactoriesLoader,加载
META\INF下的spring.factory文件 spring.factory里面是以字符串形式记录的类全限定类名- 通过反射加载到
Properties里,类似 Map 的键值对集合 - 遍历,通过反射添加到 Spring 容器 (SPI 技术)