一、原理
自动配置流程图:
@SpringBootApplication: Spring Boot应用标注在某个类上说明这个类是SpringBoot的主配置类,SpringBoot 需要运行这个类的main方法来启动SpringBoot应用
@Target(ElementType.TYPE) // 设置当前注解可以标记在哪
@Retention(RetentionPolicy.RUNTIME) //标注的类编译以什么方式保留
@Documented // java doc 会生成注解信息
@Inherited // 是否会被继承
@SpringBootConfiguration // SpringBoot的配置类
@EnableAutoConfiguration // 开启自动配置功能
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
// 扫描包 相当于在spring.xml 配置中<context:comonent-scan> 但是并没有指定basepackage,如果没有
// 指定spring底层会自动扫描当前配置类所有在的包
// excludeFilters: springboot对外提供的扩展类, 可以供我们去按照我们的方式进行排除
public @interface SpringBootApplication {
}
@EnableAutoConfiguration</