SpringBoot从入门到放弃,原理篇-自动配置原理
SpringBoot从入门到放弃,原理篇-自动配置原理 springboot自动配置原理 配置文件能配置的属性参照 自动配置原理 1、springboot启动的时候加载主配置类,开启了自动配置功能@EnableAutoConfiguration 2、@EnableAutoConfiguration 作用: 利用EnableAutoConfigurationImportSelector给容器中导入一些组件 可以查看seletcImports方法的内容 List<String> configurations = getCandidateConfigurations(annotationMetadata, attributes); 获取候选的配置 SpringFactoriesLoader.loadFactoryNames() 扫描所有jar包类路径下 META-INF/springboot.factories 把扫描到的这些文件袋额内容包装成properties对象。 从properties中获取到EnableAutoConfiguration.class类(类名)对应的值,然后把他们添加到容器中 将类路径下 META-INF/spring.factories里边配置的所有EnableAutoConfigration的值加入到了容器中; (spring-boot