自动配置原理

从SpringBoot的入口程序说起:

1、入口类上面@SpringBootApplication注解是一个组合而成的注解,主要有下面三个:

  @SpringBootConfiguration     (读取配置文件)

  @EnableAutoConfiguration    (开启自动配置)

    @ConmonentScan   (组件扫描)

2、核心注解@EnableAutoConfiguration    

  这个注解定义中包含一个@Import注解,用来导入一些配置信息,里面一个自动配置选择器selector类中有一个方法

       来扫描jar中包含spring.factories文件的jar包, 读取改配置文件的信息,找到对应的 configuration类,进行条件判断之后,

       获取对应的配置信息。

原文地址:https://www.cnblogs.com/melo-7/p/11527373.html