Skip to content

Commit ffd979c

Browse files
committed
Document missing SpringApplication events
This commit also documents `ContextRefreshedEvent` and `WebServerInitializedEvent`. Closes gh-7382
1 parent fd97066 commit ffd979c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ Application events are sent in the following order, as your application runs:
268268
except for the registration of listeners and initializers.
269269
. An `ApplicationEnvironmentPreparedEvent` is sent when the `Environment` to be used in
270270
the context is known but before the context is created.
271+
. An `ApplicationContextInitializedEvent` is sent when the `ApplicationContext` is prepared
272+
and ApplicationContextInitializers have been called but before any bean definitions are loaded.
271273
. An `ApplicationPreparedEvent` is sent just before the refresh is started but after bean
272274
definitions have been loaded.
273275
. An `ApplicationStartedEvent` is sent after the context has been refreshed but before any
@@ -276,6 +278,14 @@ application and command-line runners have been called.
276278
been called. It indicates that the application is ready to service requests.
277279
. An `ApplicationFailedEvent` is sent if there is an exception on startup.
278280

281+
The above list only includes `SpringApplicationEvent`s that are tied to a `SpringApplication`.
282+
In addition to these, the following events are also published after `ApplicationPreparedEvent`
283+
and before `ApplicationStartedEvent`:
284+
285+
. A `ContextRefreshedEvent` is sent when an `ApplicationContext` is refreshed.
286+
. A `WebServerInitializedEvent` is sent after the `WebServer` is ready. `ServletWebServerInitializedEvent`
287+
and `ReactiveWebServerInitializedEvent` are the servlet and reactive variants respectively.
288+
279289
TIP: You often need not use application events, but it can be handy to know that they
280290
exist. Internally, Spring Boot uses events to handle a variety of tasks.
281291

0 commit comments

Comments
 (0)