1

ApplicationStartedEvent与ContextStartedEvent有区别吗?

 2 years ago
source link: https://blog.didispace.com/difference-between-applicationstartedevent-contextstartedevent/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

ApplicationStartedEvent与ContextStartedEvent有区别吗?

大家好,我是DD!

今天跟大家聊聊这个问题:ApplicationStartedEvent与ContextStartedEvent有区别吗?

对了,最近花了几周时间,把SpringForAll社区 3.0上线了,社区的建设目标与之前一样,希望能够构建一个垂直于Java开发者的高质量技术社区!目前,已经有接近1000名注册用户,每天也有不少读者会发布一些帖子,技术氛围已经初步形成。

如果你正在学习Java、Spring,你可以在这里分享你的见解,碰到的问题以及帮助别人解决问题。
后面,我会持续精选一些,我觉得有意思的问题,在这里继续给大家分享一下!

关于这个问题,其实就是Spring和Spring Boot事件机制的理解。

虽然Spring Boot的基础是Spring,但Spring Boot并没有直接使用Spring中定义的常用事件,而是重新定义了一批。

它们都是继承自SpringApplicationEvent,而SpringApplicationEvent继承自ApplicationEventSpringApplicationEvent与题主提到的ContextStartedEvent是平级的。

所以,Spring Boot中应该是没用到ContextStartedEvent的

Spring Boot具体有哪些事件可以看看之前在2.0发布的时候写过一篇:《Spring Boot 2.0 新特性(二):新增事件ApplicationStartedEvent

ApplicationStartingEvent
ApplicationEnvironmentPreparedEvent
ApplicationPreparedEvent
ApplicationStartedEvent <= 新增的事件
ApplicationReadyEvent
ApplicationFailedEvent

今天的分享就到这里!如果您学习过程中如遇困难?可以加入我们超高质量的Spring技术交流群,参与交流与讨论,更好的学习与进步!更多Spring Boot教程可以点击直达!,欢迎收藏与转发支持!

以上是我的认识,如果有不对的地方,也欢迎评论区指出,一起学习一起进阶!


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK