发布ApplicationStartedEvent事件和AvailabilityChangeEvent事件,AvailabilityChangeEvent事件
表示状态变更状态,变更后的状态为LivenessState.
CORRECT
LivenessState枚举有两个值:
????????1.
CORRECT:表示当前应用正常运行中
????????2.
BROKEN:表示当前应用还在运行,但是内部出现问题,暂时还没发现哪里用到了
17、调用ApplicationRunner和CommandLineRunner
????????1.
获取Spring容器中的ApplicationRunner类型的Bean
????????2.
获取Spring容器中的CommandLineRunner类型的Bean
????????3.
执行它们的run()
18、触发SpringApplicationRunListener的ready()
????????发布ApplicationReadyEvent事件和AvailabilityChangeEvent事件,AvailabilityChangeEvent事件 表示状态变更状态,变更后的状态为ReadinessState.
ACCEPTING_TRAFFIC
ReadinessState枚举有两个值:
????????1.
ACCEPTING_TRAFFIC:表示当前应用准备接收请求
????????2.
REFUSING_TRAFFIC:表示当前应用拒绝接收请求,比如Tomcat关闭时,就会发布AvailabilityChangeEvent事 件,并且状态为REFUSING_TRAFFIC
19、上述过程抛异常了就触发SpringApplicationRunListener的failed()
????????发布ApplicationFailedEvent事件
配置文件解析
流程图:
https://www.processon.com/view/link/62d399e71e08530a89222b23
SpringBoot完整的配置优先级
https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.extern
al-config
优先级由低到高(注意和我写的顺序是反的,我写的是由高到底)
1.
Default properties (specified by setting SpringApplication.setDefaultProperties
).
2.
@PropertySource
annotations on your
@Configuration
classes. Please note that such property sources
are not added to the
Environment
until the application context is being refreshed. This is too late to configure certain properties such as
logging.*
and
spring.main.*
which are read before refresh begins.
3.
Config data (such as application.properties
files).
4.
A RandomValuePropertySource
that has properties only in
random.*
.
5.
OS environment variables.
6.
Java System properties (System.getProperties()
).
7.
JNDI attributes from java:comp/env
. 不管它
8.
ServletContext
init parameters.
9.
ServletConfig
init parameters.
10.
Properties from SPRING_APPLICATION_JSON
(inline JSON embedded in an environment variable or system property).
11.
Command line arguments.
12.
properties
attribute on your tests. Available on
@SpringBootTest
and the
test annotations for testing
a particular slice of your application
.
13.
@TestPropertySource
annotations on your tests.
14.
Devtools global settings properties
in the
$HOME/.config/spring-boot
directory when devtools is active.