Skip to content

Commit d5980be

Browse files
committed
Clarify documentation for relaxed binding of environment variables
Closes gh-22974
1 parent a8b8f43 commit d5980be

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,9 +1185,6 @@ To convert a property name in the canonical-form to an environment variable name
11851185

11861186
For example, the configuration property `spring.main.log-startup-info` would be an environment variable named `SPRING_MAIN_LOGSTARTUPINFO`.
11871187

1188-
NOTE: Underscores cannot be used to replace the dashes in property names.
1189-
If you attempt to use `SPRING_MAIN_LOG_STARTUP_INFO` with the example above, no value will be bound.
1190-
11911188
Environment variables can also be used when binding to object lists.
11921189
To bind to a `List`, the element number should be surrounded with underscores in the variable name.
11931190

@@ -1461,7 +1458,7 @@ The following table summarizes the features that are supported by `@Configuratio
14611458

14621459
| <<boot-features-external-config-relaxed-binding,Relaxed binding>>
14631460
| Yes
1464-
| Limited (see note below)
1461+
| Limited (see <<boot-features-external-config-vs-value-note,note below>>)
14651462

14661463
| <<appendix-configuration-metadata.adoc#configuration-metadata,Meta-data support>>
14671464
| Yes
@@ -1472,15 +1469,15 @@ The following table summarizes the features that are supported by `@Configuratio
14721469
| Yes
14731470
|===
14741471

1475-
If you define a set of configuration keys for your own components, we recommend you group them in a POJO annotated with `@ConfigurationProperties`.
1476-
Doing so will provide you with structured, type-safe object that you can inject into your own beans.
1477-
1478-
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).
1472+
NOTE: [[boot-features-external-config-vs-value-note]] 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).
14791473
This will allow Spring Boot to use the same logic as it does when relaxed binding `@ConfigurationProperties`.
14801474
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.
14811475
If you used `@Value("{demo.itemPrice}")` instead, `demo.item-price` and `DEMO_ITEMPRICE` would not be considered.
14821476

1483-
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>>.
1477+
If you define a set of configuration keys for your own components, we recommend you group them in a POJO annotated with `@ConfigurationProperties`.
1478+
Doing so will provide you with structured, type-safe object that you can inject into your own beans.
1479+
1480+
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>>.
14841481

14851482

14861483

0 commit comments

Comments
 (0)