Skip to content

Commit

Permalink
Merge branch '2.1.x' into 2.2.x
Browse files Browse the repository at this point in the history
Closes gh-19152
  • Loading branch information
mbhave committed Nov 27, 2019
2 parents d52935e + 53da8da commit c10c993
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
Expand Up @@ -257,11 +257,6 @@ The actual application _now_ shows the banner (as overridden by configuration) a
=== Change the Location of External Properties of an Application
By default, properties from different sources are added to the Spring `Environment` in a defined order (see "`<<spring-boot-features.adoc#boot-features-external-config>>`" in the '`Spring Boot features`' section for the exact order).

A nice way to augment and modify this ordering is to add `@PropertySource` annotations to your application sources.
Classes passed to the `SpringApplication` static convenience methods and those added using `setSources()` are inspected to see if they have `@PropertySources`.
If they do, those properties are added to the `Environment` early enough to be used in all phases of the `ApplicationContext` lifecycle.
Properties added in this way have lower priority than any added by using the default locations (such as `application.properties`), system properties, environment variables, or the command line.

You can also provide the following System properties (or environment variables) to change the behavior:

* configprop:spring.config.name[] (configprop:spring.config.name[format=envvar]): Defaults to `application` as the root of the file name.
Expand Down
Expand Up @@ -369,7 +369,7 @@ Properties are considered in the following order:
. <<boot-features-external-config-profile-specific-properties,Profile-specific application properties>> packaged inside your jar (`application-\{profile}.properties` and YAML variants).
. Application properties outside of your packaged jar (`application.properties` and YAML variants).
. Application properties packaged inside your jar (`application.properties` and YAML variants).
. {spring-framework-api}/context/annotation/PropertySource.html[`@PropertySource`] annotations on your `@Configuration` classes.
. {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).
. Default properties (specified by setting `SpringApplication.setDefaultProperties`).

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

0 comments on commit c10c993

Please sign in to comment.