File tree 3 files changed +70
-2
lines changed
springboot-source-code-analysis
src/test/java/com/example/springboot/source/code/analysis
3 files changed +70
-2
lines changed Original file line number Diff line number Diff line change
1
+ ## SpringBoot 2.1.x 框架整体启动流程
2
+
3
+ ### 1、框架初始化步骤
4
+
5
+ #### 框架初始化步骤-脑图
6
+
7
+ <img src =" https://tva1.sinaimg.cn/large/008i3skNly1gr7mstd139j311w0u01cb.jpg " alt =" image-20210605194919123 " width =" 500 " align =" left " />
8
+
9
+ #### 框架初始化步骤-源代码
10
+
11
+ > SpringBoog启动类:org.springframework.boot.SpringApplication
12
+
13
+ ``` java
14
+ @SuppressWarnings ({ " unchecked" , " rawtypes" })
15
+ public SpringApplication(ResourceLoader resourceLoader, Class<?> ... primarySources) {
16
+ // 配置资源加载器
17
+ this . resourceLoader = resourceLoader;
18
+ Assert . notNull(primarySources, " PrimarySources must not be null" );
19
+
20
+ // 配置primarySources
21
+ this . primarySources = new LinkedHashSet<> (Arrays . asList(primarySources));
22
+
23
+ // 应用环境检测
24
+ this . webApplicationType = WebApplicationType . deduceFromClasspath();
25
+
26
+ // 配置系统初始化器
27
+ setInitializers((Collection ) getSpringFactoriesInstances(ApplicationContextInitializer . class));
28
+
29
+ // 配置应用监听器
30
+ setListeners((Collection ) getSpringFactoriesInstances(ApplicationListener . class));
31
+
32
+ // 配置main方法所在的类
33
+ this . mainApplicationClass = deduceMainApplicationClass();
34
+ }
35
+ ```
36
+
37
+
38
+
39
+ ### 2、启动框架
40
+
41
+ #### 启动框架-流程
42
+
43
+ <img src =" https://tva1.sinaimg.cn/large/008i3skNly1gr7n4t8byxj32840u0b29.jpg " alt =" image-20210605200051981 " align =" left " width =" 1000 " />
44
+
45
+
46
+
47
+ ### 3、框架自动化装配步骤
48
+
49
+ #### 自动化装配-脑图
50
+
51
+ <img src =" https://tva1.sinaimg.cn/large/008i3skNly1gr7n6t3qd2j31n80ju12l.jpg " alt =" image-20210605200241401 " width =" 500 " align =" left " />
52
+
53
+
54
+
55
+
56
+
57
+ ### 4、SpringBoot上下文
58
+
59
+ #### 准备上下文流程
60
+
61
+ <img src =" https://tva1.sinaimg.cn/large/008i3skNly1gr7nby7ctij30y40t4dt7.jpg " alt =" image-20210605200740395 " width =" 650 " align =" left " />
62
+
63
+
64
+
65
+ #### 刷新上下文流程
66
+
67
+ <img src =" https://tva1.sinaimg.cn/large/008i3skNly1gr7ngcduz6j31ym0u07ql.jpg " alt =" image-20210605201154951 " align =" left " />
68
+
Original file line number Diff line number Diff line change 5
5
<parent >
6
6
<groupId >org.springframework.boot</groupId >
7
7
<artifactId >spring-boot-starter-parent</artifactId >
8
- <version >2.4.0 </version >
8
+ <version >2.1.7.RELEASE </version >
9
9
<relativePath /> <!-- lookup parent from repository -->
10
10
</parent >
11
11
<groupId >com.ipman.source.code.analysis.springboot</groupId >
Original file line number Diff line number Diff line change 1
1
package com .example .springboot .source .code .analysis ;
2
2
3
- import org .junit .jupiter . api . Test ;
3
+ import org .junit .Test ;
4
4
import org .springframework .boot .test .context .SpringBootTest ;
5
5
6
6
@ SpringBootTest
You can’t perform that action at this time.
0 commit comments