当一个Application运行时,会发送如下事件:
- ApplicationStartingEvent
运行run在注册完监听器与初始化器后,处理其他前触发。(测试的时候发现监听不到这个事件,暂时还不知道原因) - ApplicationEnvironmentPreparedEvent
当Environment已经准备好,在context 创建前。 - ApplicationContextInitializedEvent
在ApplicationContext 创建和ApplicationContextInitializer都被调用后,但是bean definition没有被加载前。 - ApplicationPreparedEvent
bean definition已经加载,但是没有refresh。 - ApplicationStartedEvent
context 已经被refresh, 但是application 和command-line 的runner都没有被调用。 - AvailabilityChangeEvent
带上LivenessState.CORRECT标志,标识应用是活的。 - ApplicationReadyEvent
application 和command-line 的runner都被调用后。 - AvailabilityChangeEvent
带上ReadinessState.ACCEPTING_TRAFFIC标志,标识应用可以提供服务。 - ApplicationFailedEvent
启动过程中,抛异常了。
另外还在如下事件在ApplicationPreparedEvent 之后和ApplicationStartedEvent之前发送
- WebServerInitializedEvent
WebServer已经准备好
1.1 ServletWebServerInitializedEvent
servlet 准备好
1.2 ReactiveWebServerInitializedEvent
reactive 准备好 - ContextRefreshedEvent
ApplicationContext已经refresh。