Skip to content

Commit a2451a4

Browse files
committed
Merge branch '2.1.x' into 2.2.x
Closes gh-19152
2 parents e9cbed8 + b46bb72 commit a2451a4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ It is therefore possible to get the location of the file from the environment.
103103
The preceding example adds the `custom-resource` property source at the end of the list so that a key defined in any of the usual other locations takes precedence.
104104
A custom implementation may define another order.
105105

106-
CAUTION: While using `@PropertySource` on your `@SpringBootApplication` may seem to be a convenient and easy way to load a custom resource in the `Environment`, we do not recommend it, because Spring Boot prepares the `Environment` before the `ApplicationContext` is refreshed.
107-
Any key defined with `@PropertySource` is loaded too late to have any effect on auto-configuration.
106+
CAUTION: While using `@PropertySource` on your `@SpringBootApplication` may seem to be a convenient way to load a custom resource in the `Environment`, we do not recommend it.
107+
Such property sources are not added to the `Environment` until the application context is being refreshed.
108+
This is too late to configure certain properties such as `logging.*` and `spring.main.*` which are read before refresh begins.
108109

109110

110111

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,9 @@ Properties are considered in the following order:
369369
. <<boot-features-external-config-profile-specific-properties,Profile-specific application properties>> packaged inside your jar (`application-\{profile}.properties` and YAML variants).
370370
. Application properties outside of your packaged jar (`application.properties` and YAML variants).
371371
. Application properties packaged inside your jar (`application.properties` and YAML variants).
372-
. {spring-framework-api}/context/annotation/PropertySource.html[`@PropertySource`] annotations on your `@Configuration` classes (these are added late to the `Environment` and will not have any effect on anything that reads properties from the `Environment` before the `ApplicationContext` is refreshed, such as logging configuration and auto-configuration).
372+
. {spring-framework-api}/context/annotation/PropertySource.html[`@PropertySource`] annotations on your `@Configuration` classes.
373+
Please note that such property sources are not added to the `Environment` until the application context is being refreshed.
374+
This is too late to configure certain properties such as `logging.*` and `spring.main.*` which are read before refresh begins.
373375
. Default properties (specified by setting `SpringApplication.setDefaultProperties`).
374376

375377
To provide a concrete example, suppose you develop a `@Component` that uses a `name` property, as shown in the following example:

0 commit comments

Comments
 (0)