Do ApplicationStartedEvent and ContextStartedEvent Differ in Spring Boot?
This article explains the distinction between Spring Boot’s ApplicationStartedEvent and the traditional ContextStartedEvent, clarifies that Spring Boot defines its own set of events inheriting from SpringApplicationEvent, and lists the core events introduced in Spring Boot 2.0.
Hello, I'm DD!
Let's discuss whether ApplicationStartedEvent and ContextStartedEvent differ.
The issue concerns the event mechanisms of Spring and Spring Boot. Although Spring Boot builds on Spring, it does not directly use the common events defined in Spring; instead it defines a new set.
These events all inherit from SpringApplicationEvent, which itself extends ApplicationEvent. SpringApplicationEvent and ContextStartedEvent are on the same hierarchy level.
Therefore, Spring Boot does not use ContextStartedEvent.
For a full list of Spring Boot events introduced in version 2.0, see the code snippet below:
ApplicationStartingEvent
ApplicationEnvironmentPreparedEvent
ApplicationPreparedEvent
ApplicationStartedEvent <= newly added event
ApplicationReadyEvent
ApplicationFailedEventSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
