::
::
::
::
::
# SpringBoot的run方法流程分析
![61080963898](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154520387-140576031.png)
1. 开始启动Springboot应用
![61080969735](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154520101-1614743777.png)
2. 构建一个SpringBoot应用
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081061275](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154519587-2107774182.png)
![61081482999](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154519302-71261341.png)
2.1.SpringApplication.run()启动此应用
![61081534938](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154514604-1518179927.png)
![61081534053](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154518788-843794037.png)
2.2.启动启动计时器开始计时应用启动监听器开始监听
![61081534938](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154514604-1518179927.png)
![61081573762](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154518277-1499012465.png)
2.3.SpringApplicationRunListeners应用启动监听器模块
2.4.ConfigurationEnvironment配置环境模块
2.4.1. 创建配置环境(web/noweb)
![61081534938](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154514604-1518179927.png)
![61081723084](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154517740-282449512.png)
![61081728158](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154517377-1303151600.png)
2.4.2. 加载属性文件资源
![61081534938](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154514604-1518179927.png)
![61081737912](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154516866-1090941457.png)
![61081754263](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154516580-1299273823.png)
![61081762818](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154516245-856244925.png)
![61081759512](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154515951-1326632968.png)
2.4.3. 配置监听
![61081534938](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154514604-1518179927.png)
![61081821517](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154515399-733763164.png)
2.5.Banner配置SpringBoot彩蛋
![61081534938](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154514604-1518179927.png)
![61081581474](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154514870-1458790288.png)
2.6.ConfigurableApplicationContext应用上下文模块
![61081534938](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154514604-1518179927.png)
![61081607987](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154514327-449531221.png)
2.6.1. 创建应用上下文对象(web/noweb)
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61081895096](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154513825-235365510.png)
![61081897427](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154513593-1587027768.png)
![61081900597](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154513305-1492168182.png)
2.6.2. 基础属性配置
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61081939697](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154512712-192165894.png)
2.6.2.1. 加载配置环境
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61081984527](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154512093-258617764.png)
2.6.2.2. ResourceLoader资源加载器
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61082002001](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154510311-119549503.png)
![61082004002](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154511233-1553495722.png)
![61082012695](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154510896-1869102535.png)
2.6.2.3. 配置监听
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61082002001](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154510311-119549503.png)
![61082029380](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154510030-2061685806.png)
![61082032335](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154509721-1709977781.png)
![61082031076](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154509458-1585518020.png)
2.6.2.4. 加载启动参数
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61082044197](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154508913-2008652015.png)
2.6.3. 更新应用上下文
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61081952226](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154508302-355303927.png)
2.6.3.1. 准备环境所需bean工程
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61082128010](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154507742-1145264965.png)
2.6.3.2. 通过工厂产生环境所需bean
![61082067261](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154507481-656668381.png)
![61082076556](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154507198-532601635.png)
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61082095418](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154505309-974539108.png)
2.6.3.3. 应用启动计时器结束计时应用启动监听器结束监听
![61081895880](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506341-623689135.png)
![61082155867](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154506111-1035936553.png)
![61082156529](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154505873-343392011.png)
2.6.3.4. SpringApplication启动结束
![61082184159](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154505650-930554644.png)
![61082095418](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154505309-974539108.png)
![61082185493](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154504873-512364752.png)
3. 初始化模块
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081035906](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154504341-413960979.png)
4. 配置source
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081074215](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154503825-1391033635.png)
5. 配置是否web环境
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081076277](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154503163-1752115966.png)
6. 创建初始化构造器
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081079755](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154502630-399241339.png)
![61081115491](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154502331-808690988.png)
6.1. 得到所需工厂集合的实例
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081217546](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154501719-1794899519.png)
6.2. 获取传入的工厂类名、类加载器
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081224684](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154500999-1213620526.png)
![61081285682](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154500083-1041293655.png)
![61081237378](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154500384-528315673.png)
6.3. 通过类加载器、获取指定的spring.factories文件
![61081285682](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154500083-1041293655.png)
![61081288017](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154459872-275849430.png)
![61081244379](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154459577-399093222.png)
6.4. 获取文件中工厂类的全路径
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081312453](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154459052-389774778.png)
6.5. 通过类路径反射得到工厂的class对象、构造方法
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081317586](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154458497-858238830.png)
![61081335555](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154458196-1334477169.png)
6.6. 生成工厂实例返回
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081325619](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154457643-1873007994.png)
7. 创建应用监听器
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081081632](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154457127-1039847082.png)
8. 配置应用的主方法所在类
![61081249186](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456841-662367312.png)
![61081084105](https://img2022.cnblogs.com/blog/2848680/202204/2848680-20220423154456545-1732828756.png)
posted on
2022-04-23 16:57
ofanimon
阅读(
116)
评论()
编辑
收藏
举报
// 侧边栏目录
// https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css