Skip to content

Commit d041c7d

Browse files
committed
Document the granularity for property document imports
Closes gh-22987
1 parent 932fb65 commit d041c7d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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

+18-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ If you've already directly <<boot-features-external-config-files-importing,impor
711711
[[boot-features-external-config-files-importing]]
712712
==== Importing Additional Data
713713
Application properties may import further config data from other locations using the `spring.config.import` property.
714-
Imports are processed as they are discovered, and are treated as an additional documents inserted immediately below the one that declares the import.
714+
Imports are processed as they are discovered, and are treated as additional documents inserted immediately below the one that declares the import.
715715

716716
For example, you might have the following in your classpath `application.properties` file:
717717

@@ -727,6 +727,23 @@ For example, you might have the following in your classpath `application.propert
727727
This will trigger the import of a `dev.properties` file in current directory (if such a file exists).
728728
Values from the imported `dev.properties` will take precedence over the file that triggered the import.
729729
In the above example, the `dev.properties` could redefine `spring.application.name` to a different value.
730+
An import will only be imported once no matter how many times it is declared.
731+
The order an import is defined inside a single document within the properties/yaml file doesn't matter.
732+
For instance, the two examples below produce the same result:
733+
734+
[source,yaml,indent=0,configblocks]
735+
----
736+
spring.config.import=my.properties
737+
my.property=value
738+
----
739+
740+
[source,yaml,indent=0,configblocks]
741+
----
742+
my.property=value
743+
spring.config.import=my.properties
744+
----
745+
746+
In both of the above examples, the values from the `my.properties` file will take precedence over the file that triggered its import.
730747

731748
Several locations can be specified under a single `spring.config.import` key.
732749
Locations will be processed in the order that they are defined, with later imports taking precedence.

0 commit comments

Comments
 (0)