springboot源码略读

     springboot的精髓是自动依赖注入。那么哪些能自动注入呢,打开spring-boot-autoconfigure,jar下的spring.factories。

     可以看到一堆这样的配置:

# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\
org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\
org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\
org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\
org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\

让我们随便点开一个文件,AopAutoConfiguration,

springboot源码略读

这里的就能看到我们能写在配置文件里的配置。

真正的加载原理在

SpringApplication.class这个类中,位于第138的run方法中,
createApplicationContext()这个方法进行加载。