Skip to content

Commit 6ccba24

Browse files
committed
Merge branch '2.2.x'
Close gh-20507 in 2.3.0.RC1
2 parents 96baf27 + 581ce09 commit 6ccba24

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

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

15571557
| <<boot-features-external-config-relaxed-binding,Relaxed binding>>
15581558
| Yes
1559-
| No
1559+
| Limited (see note below)
15601560

15611561
| <<appendix-configuration-metadata.adoc#configuration-metadata,Meta-data support>>
15621562
| Yes
@@ -1568,7 +1568,12 @@ The following table summarizes the features that are supported by `@Configuratio
15681568
|===
15691569

15701570
If you define a set of configuration keys for your own components, we recommend you group them in a POJO annotated with `@ConfigurationProperties`.
1571-
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.
1571+
Doing so will provide you with structured, type-safe object that you can inject into your own beans.
1572+
1573+
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).
1574+
This will allow Spring Boot to use the same logic as it does when relaxed binding `@ConfigurationProperties`.
1575+
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.
1576+
If you used `@Value("{demo.itemPrice}")` instead, `demo.item-price` and `DEMO_ITEMPRICE` would not be considered.
15721577

15731578
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>>.
15741579

0 commit comments

Comments
 (0)