Spring boot启动之事件发布
Spring boot启动过程要发布一系列事件,来完成Spring boot各阶段任务的有序进行。其中包括ApplicationStartingEvent、ApplicationEnvironmentPreparedEvent、ApplicationContextInitializedEvent、ApplicationPreparedEvent、ApplicationStartedEvent 、ApplicationReadyEvent。
1. ApplicationStartingEvent
LoggingApplicationListener
BackgroundPreInitializer
DelegatingApplicationListener
LiquibaseServiceLocatorApplicationListener
2. ApplicationEnvironmentPreparedEvent
EnvironmentPostProcesserApplicationListener
AnsiOutputApplicationListener
LoggingApplicationListener
BackgroundPreInitializer
DelegatingApplicationListener
FileEncodingApplicationListener
3. ApplicationContextInitializedEvent
BackgroundPreInitializer
DelegatingApplicationListener
3.1 BootstrapCOntextClosedEvent
无监听器监听
4. ApplicationPreparedEvent
EnvironmentPostProcesserApplicationListener
LoggingApplicationListener
BackgroundPreInitializer
DelegatingApplicationListener
4.1 ServletWebServerInitializedEvent
SpringApplicationAdminMXBeanRegistrar
DelegatingApplicationListener
ServerPortInfoApplicationContextInitializer
4.2 ContextRefreshedEvent
DelegatingApplicationListener
ConditionEvaluationReportLoggingListenerSharedMetadataReaderFactoryBean
RourceUrlProvider
5. ApplicationStartedEvent
BackgroundPreInitializer
DelegatingApplicationListener
5.1 AvailabilityChangeEvent
DelegatingApplicationListener
ApplicationAvailabilityBean
6. ApplicationReadyEvent
SpringApplicationAdminMXBeanRegistrar
BackgroundPreInitializer
DelegatingApplicationListener
6.1 AvailabilityChangeEvent
与5.1 同