Skip to content

Commit 581ce09

Browse files
committed
Merge branch '2.1.x' into 2.2.x
Closes gh-21106
2 parents db28c0c + 416cfc2 commit 581ce09

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ The following table summarizes the features that are supported by `@Configuratio
14481448

14491449
| <<boot-features-external-config-relaxed-binding,Relaxed binding>>
14501450
| Yes
1451-
| No
1451+
| Limited (see note below)
14521452

14531453
| <<appendix-configuration-metadata.adoc#configuration-metadata,Meta-data support>>
14541454
| Yes
@@ -1460,7 +1460,12 @@ The following table summarizes the features that are supported by `@Configuratio
14601460
|===
14611461

14621462
If you define a set of configuration keys for your own components, we recommend you group them in a POJO annotated with `@ConfigurationProperties`.
1463-
You should also be aware that, since `@Value` does not support relaxed binding, it is not a good candidate if you need to provide the value by using environment variables.
1463+
Doing so will provide you with structured, type-safe object that you can inject into your own beans.
1464+
1465+
If you do want to use `@Value`, we recommend that you refer to property names using their canonical form (kebab-case using only lowercase letters).
1466+
This will allow Spring Boot to use the same logic as it does when relaxed binding `@ConfigurationProperties`.
1467+
For example, `@Value("{demo.item-price}")` will pick up `demo.item-price` and `demo.itemPrice` forms from the `application.properties` file, as well as `DEMO_ITEMPRICE` from the system environment.
1468+
If you used `@Value("{demo.itemPrice}")` instead, `demo.item-price` and `DEMO_ITEMPRICE` would not be considered.
14641469

14651470
Finally, while you can write a `SpEL` expression in `@Value`, such expressions are not processed from <<boot-features-external-config-application-property-files,application property files>>.
14661471

0 commit comments

Comments
 (0)