Skip to content

Commit 9ac5151

Browse files
committed
Merge branch '2.3.x' into 2.4.x
Closes gh-25064
2 parents d7c44e4 + 19c5864 commit 9ac5151

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

+12-7
Original file line numberDiff line numberDiff line change
@@ -1489,9 +1489,10 @@ TIP: We recommend that, when possible, properties are stored in lower-case kebab
14891489

14901490
[[boot-features-external-config-relaxed-binding-maps]]
14911491
===== Binding Maps
1492-
When binding to `Map` properties, if the `key` contains anything other than lowercase alpha-numeric characters or `-`, you need to use the bracket notation so that the original value is preserved.
1493-
If the key is not surrounded by `[]`, any characters that are not alpha-numeric or `-` are removed.
1494-
For example, consider binding the following properties to a `Map`:
1492+
When binding to `Map` properties you may need to use a special bracket notation so that the original `key` value is preserved.
1493+
If the key is not surrounded by `[]`, any characters that are not alpha-numeric, `-` or `.` are removed.
1494+
1495+
For example, consider binding the following properties to a `Map<String,String>`:
14951496

14961497

14971498
[source,properties,indent=0,role="primary"]
@@ -1507,14 +1508,18 @@ For example, consider binding the following properties to a `Map`:
15071508
----
15081509
acme:
15091510
map:
1510-
"[/key1]": value1
1511-
"[/key2]": value2
1512-
"/key3": value3
1511+
"[/key1]": "value1"
1512+
"[/key2]": "value2"
1513+
"/key3": "value3"
15131514
----
15141515

1516+
NOTE: For YAML files, the brackets need to be surrounded by quotes for the keys to be parsed properly.
1517+
15151518
The properties above will bind to a `Map` with `/key1`, `/key2` and `key3` as the keys in the map.
1519+
The slash has been removed from `key3` because it wasn't surrounded by square brackets.
15161520

1517-
NOTE: For YAML files, the brackets need to be surrounded by quotes for the keys to be parsed properly.
1521+
You may also occasionally need to use the bracket notation if your `key` contains a `.` and you are binding to non-scalar value.
1522+
For example, binding `a.b=c` to `Map<String, Object>` will return a Map with the entry `{"a"={"b"="c"}}` where as `[a.b]=c` will return a Map with the entry `{"a.b"="c"}`.
15181523

15191524

15201525

0 commit comments

Comments
 (0)