欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > 能源 > spring-boot 事件

spring-boot 事件

2024/10/24 21:36:29 来源:https://blog.csdn.net/TheThirdMoon/article/details/141825826  浏览:    关键词:spring-boot 事件
事件触发时机常用监听器描述
ApplicationStartingEvent应用启动时LoggingApplicationListener:决定加载哪个日志系统
ApplicationEnvironmentPreparedEvent创建Environment之后BootstrapApplicationListener:加载spring-cloud bootstrap配置文件;
LoggingSystemShutdownListener:清理日志系统资源;
EnvironmentPostProcessorApplicationListener:调用EnvironmentPostProcessor实现类,如加载application-*.yml配置文件;
LoggingApplicationListener:初始化日志系统;
BackgroundPreinitializer:异步执行一些与初始化任务;
DelegatingApplicationListener:读取配置文件中的context.listener.classes 自定义监听器类,实例化并在加入(自定义监听器的顺序是独立的)
ApplicationContextInitializedEvent创建applicationContext并调用ApplicationContextInitializer之后
ApplicationPreparedEvent加载xml bean文件之后LoggingApplicationListener:将日志系统注入容器
ContextRefreshedEventrefreshContext流程结束之后RestartListener:重启后重新出发ApplicationEnvironmentPreparedEvent事件
ApplicationStartedEvent自定义afterRefresh方法调用之后
ApplicationReadyEventspring-boot启动结束时
ApplicationFailedEventspring-boot启动失败时
ContextClosedEventParentContextCloserApplicationListener:在context关闭时,同时关闭父contenxt
spring-boot 启动时的事件顺序
ApplicationStartingEvent
ApplicationEnvironmentPreparedEvent
ApplicationContextInitializedEvent
ApplicationPreparedEvent
ContextRefreshedEvent
ApplicationStartedEvent
ApplicationReadyEvent

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com