Skip to content

Commit d69565c

Browse files
committed
Merge branch '2.4.x'
Closes gh-25346
2 parents 91e16e1 + 34150d0 commit d69565c

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
@@ -914,8 +914,6 @@ The `SpringApplication` class automatically supports YAML as an alternative to p
914914

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

917-
918-
919917
==== Mapping YAML to Properties
920918
YAML documents need to be converted from their hierarchical format to a flat structure that can be used with the Spring `Environment`.
921919
For example, consider the following YAML document:
@@ -964,6 +962,9 @@ The preceding example would be transformed into these properties:
964962
TIP: Properties that use the `[index]` notation can be bound to Java `List` or `Set` objects using Spring Boot's `Binder` class.
965963
For more details see the "`<<boot-features-external-config-typesafe-configuration-properties>>`" section below.
966964

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

968969

969970
[[boot-features-external-config-loading-yaml]]
@@ -975,34 +976,6 @@ The `YamlPropertiesFactoryBean` loads YAML as `Properties` and the `YamlMapFacto
975976
You can also use the `YamlPropertySourceLoader` class if you want to load YAML as a Spring `PropertySource`.
976977

977978

978-
979-
[[boot-features-external-config-yaml-shortcomings]]
980-
==== YAML Shortcomings
981-
YAML files cannot be loaded by using the `@PropertySource` annotation.
982-
So, in the case that you need to load values that way, you need to use a properties file.
983-
984-
Using the multi-document YAML syntax in profile-specific YAML files can lead to unexpected behavior.
985-
For example, consider the following config in a file:
986-
987-
.application-dev.yml
988-
[source,yaml,indent=0]
989-
----
990-
server.port: 8000
991-
---
992-
spring.config.activate.on-profile: "!test"
993-
mypassword: "secret"
994-
----
995-
996-
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.
997-
998-
The nested document will be filtered because the main file is named `application-dev.yml`.
999-
It is already considered to be profile-specific, and nested documents will be ignored.
1000-
1001-
TIP: We recommend that you don't mix profile-specific YAML files and multiple YAML documents.
1002-
Stick to using only one of them.
1003-
1004-
1005-
1006979
[[boot-features-external-config-random-values]]
1007980
=== Configuring Random Values
1008981
The `RandomValuePropertySource` is useful for injecting random values (for example, into secrets or test cases).

0 commit comments

Comments
 (0)