Clarify "YAML Shortcomings" documentation
Closes gh-17933
This commit is contained in:
parent
ffbd11caba
commit
7e60f4b32a
|
|
@ -691,22 +691,28 @@ YAML files cannot be loaded by using the `@PropertySource` annotation.
|
||||||
So, in the case that you need to load values that way, you need to use a properties file.
|
So, in the case that you need to load values that way, you need to use a properties file.
|
||||||
|
|
||||||
Using the multi YAML document syntax in profile-specific YAML files can lead to unexpected behavior.
|
Using the multi YAML document syntax in profile-specific YAML files can lead to unexpected behavior.
|
||||||
For example, consider the following config in a file called `application-dev.yml`, with the `dev` profile being active:
|
For example, consider the following config in a file:
|
||||||
|
|
||||||
|
.application-dev.yml
|
||||||
[source,yaml,indent=0]
|
[source,yaml,indent=0]
|
||||||
----
|
----
|
||||||
server:
|
server:
|
||||||
port: 8000
|
port: 8000
|
||||||
---
|
---
|
||||||
spring:
|
spring:
|
||||||
profiles: !test
|
profiles: "!test"
|
||||||
security:
|
security:
|
||||||
user:
|
user:
|
||||||
password: weak
|
password: "secret"
|
||||||
----
|
----
|
||||||
|
|
||||||
In the example above, profile negation and profile expressions will not behave as expected.
|
If you run the application with the arguments `--spring.profiles.active=dev" you might expect `security.user.password` to be set to "`secret`", but this is not the case.
|
||||||
We recommend that you don't combine profile-specific YAML files and multiple YAML documents and stick to using only one of them.
|
|
||||||
|
The nested document will be filtered because the main file is named `application-dev.yml`.
|
||||||
|
It is already considered to be profile-specific, and nested documents will be ignored.
|
||||||
|
|
||||||
|
TIP: We recommend that you don't mix profile-specific YAML files and multiple YAML documents.
|
||||||
|
Stick to using only one of them.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue