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.

Programmer DD
Programmer DD
Programmer DD
Do ApplicationStartedEvent and ContextStartedEvent Differ in Spring Boot?

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
ApplicationFailedEvent
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

spring-bootapplication-events
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.