Skip to content

Commit 29f1bd9

Browse files
committed
Make it clearer that default config locations are always used
Closes gh-4062
1 parent 85862e6 commit 29f1bd9

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,31 @@ being loaded, including profile-specific file names). Files specified in
551551
`spring.config.location` are used as-is, with no support for profile-specific variants,
552552
and will be overridden by any profile-specific properties.
553553

554-
The default search path `classpath:,classpath:/config,file:,file:config/`
555-
is always used, irrespective of the value of `spring.config.location`. This search path
556-
is ordered from lowest to highest precedence (`file:config/` wins). If you do specify
557-
your own locations, they take precedence over all of the default locations and use the
558-
same lowest to highest precedence ordering. In that way you can set up default values for
559-
your application in `application.properties` (or whatever other basename you choose with
560-
`spring.config.name`) and override it at runtime with a different file, keeping the
561-
defaults.
554+
Config locations are searched in reverse order. By default, the configured locations are
555+
`classpath:/,classpath:/config/,file:./,file:./config/`. The resulting search order is:
556+
557+
1. `file:./config/`
558+
2. `file:./`
559+
3. `classpath:/config/`
560+
4. `classpath:/`
561+
562+
When custom config locations are configured, they are used in addition to the default
563+
locations. Custom locations are searched before the default locations. For example,
564+
if custom locations `classpath:/custom-config/,file:./custom-config/` are configured, the search order becomes:
565+
566+
1. `file:./custom-config/`
567+
2. `classpath:custom-config/`
568+
3. `file:./config/`
569+
4. `file:./`
570+
5. `classpath:/config/`
571+
6. `classpath:/`
572+
573+
This search ordering allows you to specify default values in one configuration file
574+
and then selectively override those values in another. You can provide default values
575+
for you application in `application.properties` (or whatever other basename you choose
576+
with `spring.config.name`) in one of the default locations. These default values can
577+
then be overriden at runtime with a different file located in one of the custom
578+
locations.
562579

563580
NOTE: If you use environment variables rather than system properties, most operating
564581
systems disallow period-separated key names, but you can use underscores instead (e.g.

0 commit comments

Comments
 (0)