Skip to content

Commit 856c83f

Browse files
authored
Update 23.5. Application events and listeners.md
1 parent ce1df4c commit 856c83f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

IV. Spring Boot features/23.5. Application events and listeners.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
org.springframework.context.ApplicationListener=com.example.project.MyListener
88
```
99

10-
你可以使用多种方式注册事件监听器,最普通的是使用SpringApplication.addListeners(…)方法。在你的应用运行时,应用事件会以下面的次序发送
10+
应用运行时,事件会以下面的次序发送
1111

1212
1. 在运行开始,但除了监听器注册和初始化以外的任何处理之前,会发送一个ApplicationStartedEvent。
1313
2. 在Environment将被用于已知的上下文,但在上下文被创建前,会发送一个ApplicationEnvironmentPreparedEvent。
1414
3. 在refresh开始前,但在bean定义已被加载后,会发送一个ApplicationPreparedEvent。
15+
4. 在refresh之后,相关的回调处理完,会发送一个ApplicationReadyEvent,表示应用准备好接收请求了。
1516
4. 启动过程中如果出现异常,会发送一个ApplicationFailedEvent。
1617

17-
****:你通常不需要使用应用程序事件,但知道它们的存在会很方便(在某些场合可能会使用到)。在Spring内部,Spring Boot使用事件处理各种各样的任务
18+
**** 通常不需要使用application事件,但知道它们的存在是有用的(在某些场合可能会使用到),比如,Spring Boot内部使用事件处理很多任务

0 commit comments

Comments
 (0)