SpringBoot部分知识
基础
自动配置原理

pom.xml:

spring-boot-dependencies:核心依赖在父工程中
引入SpringBoot依赖时,不需要指定版本,就是因为有这些版本仓库
启动器:

    <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

就是SpringBoot的启动场景
会自动帮我们导入该模块的所有依赖
启动类:

@SpringBootApplication:标注这个类是一个SpringBoot应用
两个核心注解:
@SpringBootConfiguration:SpringBoot的配置
@Configuration:Spring配置类
@Component:说明这也是一个Spring的组件
@EnableAutoConfiguration:自动配置
@AutoConfigurationPackage:自动导入包
@Import(AutoConfigurationPackages.Registrar.class):导入选择器
metadata:源数据
@Import(EnableAutoConfigurationImportSelector.class):自动配置导入选择
AutoConfigurationImportSelector:
List configurations = getCandidateConfigurations(annotationMetadata,attributes);//获取所有的配置

protected List<String> getCandidateConfigurations(AnnotationMetadata metadata,
AnnotationAttributes attributes) {
List<String> configurations = SpringFactoriesLoader.loadFactoryNames(
getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader());
Assert.notEmpty(configurations,
"No auto configuration classes found in META-INF/spring.factories. If you "
+ "are using a custom packaging, make sure that file is correct.");
return configurations;
}