一、spring-boot启动流程都做了哪些事?
- 加载配置文件
- 加载日志组件
- 创建spring容器,扫描bean并注入容器
- 启动tomcat
二、每件事是如何完成的
- 加载配置文件,通过ConfigFileApplicationListener对象加载,调用流程如下
- 加载日志组件,通过LoggingApplicationListener对象决定并加载日志组件
- 创建spring容器,扫描bean并注入容器。
- spring-boot 扫描bean依靠ConfigurationClassPostProcessor对象,该对象处理spring-boot的相关注解,扫描并注入bean
- spring-boot 通过spring-boot-autoconfigure-*.jar/META-INF/spring.factories加载一些常用的框架,如 spring-web-mvc,数据源,aop,事务,redis等
- 启动tomcat