Skip to content

Commit 93f822e

Browse files
friscoMadmbhave
authored andcommitted
Remove old documentation relating to yaml and profiles
See gh-24620
1 parent dea9b7f commit 93f822e

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

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

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,8 @@ The `SpringApplication` class automatically supports YAML as an alternative to p
984984

985985
NOTE: If you use "`Starters`", SnakeYAML is automatically provided by `spring-boot-starter`.
986986

987-
987+
WARNING: YAML files cannot be loaded by using the `@PropertySource` or `@TestPropertySource` annotations.
988+
So, in the case that you need to load values that way, you need to use a properties file.
988989

989990
==== Mapping YAML to Properties
990991
YAML documents need to be converted from their hierarchical format to a flat structure that can be used with the Spring `Environment`.
@@ -1045,34 +1046,6 @@ The `YamlPropertiesFactoryBean` loads YAML as `Properties` and the `YamlMapFacto
10451046
You can also use the `YamlPropertySourceLoader` class if you want to load YAML as a Spring `PropertySource`.
10461047

10471048

1048-
1049-
[[boot-features-external-config-yaml-shortcomings]]
1050-
==== YAML Shortcomings
1051-
YAML files cannot be loaded by using the `@PropertySource` annotation.
1052-
So, in the case that you need to load values that way, you need to use a properties file.
1053-
1054-
Using the multi-document YAML syntax in profile-specific YAML files can lead to unexpected behavior.
1055-
For example, consider the following config in a file:
1056-
1057-
.application-dev.yml
1058-
[source,yaml,indent=0]
1059-
----
1060-
server.port: 8000
1061-
---
1062-
spring.config.activate.on-profile: "!test"
1063-
mypassword: "secret"
1064-
----
1065-
1066-
If you run the application with the argument `--spring.profiles.active=dev` you might expect `mypassword` to be set to "`secret`", but this is not the case.
1067-
1068-
The nested document will be filtered because the main file is named `application-dev.yml`.
1069-
It is already considered to be profile-specific, and nested documents will be ignored.
1070-
1071-
TIP: We recommend that you don't mix profile-specific YAML files and multiple YAML documents.
1072-
Stick to using only one of them.
1073-
1074-
1075-
10761049
[[boot-features-external-config-random-values]]
10771050
=== Configuring Random Values
10781051
The `RandomValuePropertySource` is useful for injecting random values (for example, into secrets or test cases).

0 commit comments

Comments
 (0)