Skip to content

Commit 34150d0

Browse files
committed
Merge pull request #24620 from friscoMad
* pr/24620: Polish "Remove old documentation relating to yaml and profiles" Remove old documentation relating to yaml and profiles Closes gh-24620
2 parents dea9b7f + 52a1564 commit 34150d0

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

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

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,6 @@ 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-
988-
989987
==== Mapping YAML to Properties
990988
YAML documents need to be converted from their hierarchical format to a flat structure that can be used with the Spring `Environment`.
991989
For example, consider the following YAML document:
@@ -1034,6 +1032,9 @@ The preceding example would be transformed into these properties:
10341032
TIP: Properties that use the `[index]` notation can be bound to Java `List` or `Set` objects using Spring Boot's `Binder` class.
10351033
For more details see the "`<<boot-features-external-config-typesafe-configuration-properties>>`" section below.
10361034

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

10381039

10391040
[[boot-features-external-config-loading-yaml]]
@@ -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)