Change handling of spring.config.location so it replaces defaults

Previously, spring.config.name was handled in such a way that its
value would replace the defaults. By constrast, spring.config.location
would add to the defaults.

Update the handling of spring.config.location so that it replaces the
defaults. This aligns its behaviour with spring.config.name. To allow
users to add additional locations a new property,
spring.config.additional-location, has been introduced. It behaves as
spring.config.location did prior to this change.

Closes gh-10595
This commit is contained in:
Andy Wilkinson
2017-10-28 12:33:52 +01:00
parent 9b8fefb0f4
commit 8eae372433
4 changed files with 99 additions and 14 deletions

View File

@@ -555,17 +555,27 @@ before being loaded, including profile-specific file names). Files specified in
and are overridden by any profile-specific properties.
Config locations are searched in reverse order. By default, the configured locations are
`classpath:/,classpath:/config/,file:./,file:./config/`. The resulting search order is:
`classpath:/,classpath:/config/,file:./,file:./config/`. The resulting search order is the
following:
. `file:./config/`
. `file:./`
. `classpath:/config/`
. `classpath:/`
When custom config locations are configured, they are used in addition to the default
locations. Custom locations are searched before the default locations. For example, if
custom locations of `classpath:/custom-config/,file:./custom-config/` are configured, the
search order becomes:
When custom config locations are configured using `spring.config.location` they replace
the default locations. For example, if `spring.config.location` is configured with the
value `classpath:/custom-config/,file:./custom-config/`, the search order becomes the
following:
. `file:./custom-config/`
. `classpath:custom-config/`
Alternatively, when custom config locations are configured using
`spring.config.addition-location`, they are used in addition to the default locations.
Additional locations are search before the default locations. For example, if
additional locations of `classpath:/custom-config/,file:./custom-config/` are configured,
the search order becomes the following:
. `file:./custom-config/`
. `classpath:custom-config/`