1

Hello everyone, I'm DD!

Let me talk about this issue with you today: Is there a difference between ApplicationStartedEvent and ContextStartedEvent?

img

By the way, it took a few weeks recently to SpringForAll Community 3.0 on . The community construction goal is the same as before, hoping to build a high-quality technical community vertical to Java developers! At present, there are nearly 1,000 registered users, and many readers will publish some posts every day, and the technical atmosphere has initially formed.
img
If you are learning Java, Spring, you can share your insights, encountered problems and help others solve problems here.
Later, I will continue to select some questions that I find interesting, and I will continue to share them with you here!

Regarding this issue, it is actually the understanding of Spring and Spring Boot event mechanism.

Although Spring Boot is based on Spring, Spring Boot does not directly use the common events defined in Spring, but redefines a batch.

They all inherit from SpringApplicationEvent , and SpringApplicationEvent inherits from ApplicationEvent , SpringApplicationEvent and ContextStartedEvent mentioned in the title are equal.

Therefore, ContextStartedEvent should not be used in Spring Boot.

What are the specific events of Spring Boot, you can see an article written before when 2.0 was released: ["Spring Boot 2.0 New Features (2): New Event ApplicationStartedEvent
》](https://blog.didispace.com/Spring-Boot-2-0-feature-2-ApplicationStartedEvent/)

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

Today's sharing is here! If you encounter difficulties in the learning process? You can join our ultra-high-quality Spring technical exchange group , participate in exchanges and discussions, and learn and progress better! More Spring Boot tutorials can click directly! , welcome to collect and forward support!

The above is my understanding. If there is something wrong, please point it out in the comment area, learn and advance together!

Welcome to my public account: Programmer DD. Learn about cutting-edge industry news for the first time, share in-depth technical dry goods, and obtain high-quality learning resources

程序猿DD
2.2k 声望2.8k 粉丝

作品:《Spring Cloud微服务实战》、SpringForAll社区、OpenWrite、Youtube中文配音