温馨提示:看此文章必须具备能读spring ioc源码
首先会启动调用到:org.springframework.boot.SpringApplication#run(java.lang.String…)
通过实现了SpringApplicationRunListener接口的实现类,通过spi机制加载
META-INF/spring.factories文件下的类
spi:就是spring加载代码根目录下META-INF/spring.factories中所有的类,变为map;
图1代码详细说明:
标注2:
1.首先初始化AnnotationConfigServletWebServerApplicationContext对象,调用:org.springframework.context.annotation.AnnotationConfigUtils#registerAnnotationConfigProcessors(org.springframework.beans.factory.support.BeanDefinitionRegistry, java.lang.Object)方法把ConfigurationClassPostProcessor(此类非重要@configuration对应的),AutowiredAnnotationBeanPostProcessor(各类springIoc注解的后置处理器)等等初始化为RootBeanDefinition对象。
标注3:
1.springBoot启动的核心方法。
2.会调用org.springframework.context.support.AbstractApplicationContext#refresh做springioc相应的流程工作。