spring-boot 事件

一、spring boot事件类型
事件触发时机常用监听器描述
ApplicationStartingEvent应用启动时LoggingApplicationListener:决定加载哪个日志系统
ApplicationEnvironmentPreparedEvent创建Environment之后BootstrapApplicationListener:用于加载外部配置和初始化与 Spring Cloud 相关的组件;
LoggingSystemShutdownListener:清理日志系统资源;
EnvironmentPostProcessorApplicationListener:调用EnvironmentPostProcessor实现类,如加载application-*.yml配置文件,bootstrap配置文件;
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值