Skip to content

Commit fc408a4

Browse files
committed
Update 62.2. Customize the Environment or ApplicationContext before it starts.md
1 parent e56fb6a commit fc408a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
### 62.2. 启动前自定义Environment或ApplicationContext
22

3-
每个`SpringApplication`都有`ApplicationListeners``ApplicationContextInitializers`,用于自定义上下文(context)或环境(environment)。Spring Boot从`META-INF/spring.factories`下加载很多这样的内部使用的自定义。有很多方法可以注册其他的自定义:
3+
每个SpringApplication都有ApplicationListeners和ApplicationContextInitializers,用于自定义上下文(context)或环境(environment)。Spring Boot从`META-INF/spring.factories`下加载很多这样的内部使用的自定义。有很多方法可以注册其他的自定义:
44

55
* 以编程方式为每个应用注册自定义,通过在SpringApplication运行前调用它的`addListeners``addInitializers`方法来实现。
66
* 以声明方式为每个应用注册自定义,通过设置`context.initializer.classes``context.listener.classes`来实现。
77
* 以声明方式为所有应用注册自定义,通过添加一个`META-INF/spring.factories`并打包成一个jar文件(该应用将它作为一个库)来实现。
88

9-
`SpringApplication`会给监听器(即使是在上下文被创建之前就存在的)发送一些特定的`ApplicationEvents`,然后也会注册监听`ApplicationContext`发布的事件的监听器。查看Spring Boot特性章节中的[Section 22.4, “Application events and listeners” ](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-application-events-and-listeners)可以获取一个完整列表。
9+
SpringApplication会给监听器(即使是在上下文被创建之前就存在的)发送一些特定的ApplicationEvents,然后也会注册监听ApplicationContext发布的事件的监听器。查看Spring Boot特性章节中的[Section 22.4, “Application events and listeners” ](../IV. Spring Boot features/22.4. Application events and listeners.md)可以获取一个完整列表。

0 commit comments

Comments
 (0)