|
|
@ -711,7 +711,7 @@ If you've already directly <<boot-features-external-config-files-importing,impor
|
|
|
|
[[boot-features-external-config-files-importing]]
|
|
|
|
[[boot-features-external-config-files-importing]]
|
|
|
|
==== Importing Additional Data
|
|
|
|
==== Importing Additional Data
|
|
|
|
Application properties may import further config data from other locations using the `spring.config.import` property.
|
|
|
|
Application properties may import further config data from other locations using the `spring.config.import` property.
|
|
|
|
Imports are processed as they are discovered, and are treated as an additional documents inserted immediately below the one that declares the import.
|
|
|
|
Imports are processed as they are discovered, and are treated as additional documents inserted immediately below the one that declares the import.
|
|
|
|
|
|
|
|
|
|
|
|
For example, you might have the following in your classpath `application.properties` file:
|
|
|
|
For example, you might have the following in your classpath `application.properties` file:
|
|
|
|
|
|
|
|
|
|
|
@ -727,6 +727,23 @@ For example, you might have the following in your classpath `application.propert
|
|
|
|
This will trigger the import of a `dev.properties` file in current directory (if such a file exists).
|
|
|
|
This will trigger the import of a `dev.properties` file in current directory (if such a file exists).
|
|
|
|
Values from the imported `dev.properties` will take precedence over the file that triggered the import.
|
|
|
|
Values from the imported `dev.properties` will take precedence over the file that triggered the import.
|
|
|
|
In the above example, the `dev.properties` could redefine `spring.application.name` to a different value.
|
|
|
|
In the above example, the `dev.properties` could redefine `spring.application.name` to a different value.
|
|
|
|
|
|
|
|
An import will only be imported once no matter how many times it is declared.
|
|
|
|
|
|
|
|
The order an import is defined inside a single document within the properties/yaml file doesn't matter.
|
|
|
|
|
|
|
|
For instance, the two examples below produce the same result:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[source,yaml,indent=0,configblocks]
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
spring.config.import=my.properties
|
|
|
|
|
|
|
|
my.property=value
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[source,yaml,indent=0,configblocks]
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
my.property=value
|
|
|
|
|
|
|
|
spring.config.import=my.properties
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In both of the above examples, the values from the `my.properties` file will take precedence over the file that triggered its import.
|
|
|
|
|
|
|
|
|
|
|
|
Several locations can be specified under a single `spring.config.import` key.
|
|
|
|
Several locations can be specified under a single `spring.config.import` key.
|
|
|
|
Locations will be processed in the order that they are defined, with later imports taking precedence.
|
|
|
|
Locations will be processed in the order that they are defined, with later imports taking precedence.
|
|
|
|