You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -691,22 +691,28 @@ YAML files cannot be loaded by using the `@PropertySource` annotation.
691
691
So, in the case that you need to load values that way, you need to use a properties file.
692
692
693
693
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:
695
695
696
+
.application-dev.yml
696
697
[source,yaml,indent=0]
697
698
----
698
699
server:
699
700
port: 8000
700
701
---
701
702
spring:
702
-
profiles: !test
703
+
profiles: "!test"
703
704
security:
704
705
user:
705
-
password: weak
706
+
password: "secret"
706
707
----
707
708
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.
0 commit comments