Skip to content

Commit 7e60f4b

Browse files
committed
Clarify "YAML Shortcomings" documentation
Closes gh-17933
1 parent ffbd11c commit 7e60f4b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,22 +691,28 @@ YAML files cannot be loaded by using the `@PropertySource` annotation.
691691
So, in the case that you need to load values that way, you need to use a properties file.
692692

693693
Using the multi YAML document syntax in profile-specific YAML files can lead to unexpected behavior.
694-
For example, consider the following config in a file called `application-dev.yml`, with the `dev` profile being active:
694+
For example, consider the following config in a file:
695695

696+
.application-dev.yml
696697
[source,yaml,indent=0]
697698
----
698699
server:
699700
port: 8000
700701
---
701702
spring:
702-
profiles: !test
703+
profiles: "!test"
703704
security:
704705
user:
705-
password: weak
706+
password: "secret"
706707
----
707708

708-
In the example above, profile negation and profile expressions will not behave as expected.
709-
We recommend that you don't combine profile-specific YAML files and multiple YAML documents and stick to using only one of them.
709+
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.
710+
711+
The nested document will be filtered because the main file is named `application-dev.yml`.
712+
It is already considered to be profile-specific, and nested documents will be ignored.
713+
714+
TIP: We recommend that you don't mix profile-specific YAML files and multiple YAML documents.
715+
Stick to using only one of them.
710716

711717

712718

0 commit comments

Comments
 (0)