Commit 4e8592ff authored by Madhura Bhave's avatar Madhura Bhave

Update documentation with new relaxed rules

Closes gh-9025
parent e844c924
...@@ -74,12 +74,9 @@ rules of thumb: ...@@ -74,12 +74,9 @@ rules of thumb:
properties, thus `ServerProperties` has `prefix="server"` and its configuration properties properties, thus `ServerProperties` has `prefix="server"` and its configuration properties
are `server.port`, `server.address` etc. In a running Actuator app look at the are `server.port`, `server.address` etc. In a running Actuator app look at the
`configprops` endpoint. `configprops` endpoint.
* Look for use of `RelaxedPropertyResolver` to pull configuration values explicitly out of the * Look for uses of the `bind` method on the `Binder` to pull configuration values explicitly out of the
`Environment`. It often is used with a prefix. `Environment` in a relaxed manner. It is often is used with a prefix.
* Look for `@Value` annotations that bind directly to the `Environment`. This is less * Look for `@Value` annotations that bind directly to the `Environment`.
flexible than the `RelaxedPropertyResolver` approach, but does allow some relaxed binding,
specifically for OS environment variables (so `CAPITALS_AND_UNDERSCORES` are synonyms
for `period.separated`).
* Look for `@ConditionalOnExpression` annotations that switch features on and off in * Look for `@ConditionalOnExpression` annotations that switch features on and off in
response to SpEL expressions, normally evaluated with placeholders resolved from the response to SpEL expressions, normally evaluated with placeholders resolved from the
`Environment`. `Environment`.
...@@ -483,7 +480,7 @@ The appendix includes an <<appendix-application-properties#common-application-pr ...@@ -483,7 +480,7 @@ The appendix includes an <<appendix-application-properties#common-application-pr
`application.properties`>> example with a list of the most common properties supported by `application.properties`>> example with a list of the most common properties supported by
Spring Boot. The definitive list comes from searching the source code for Spring Boot. The definitive list comes from searching the source code for
`@ConfigurationProperties` and `@Value` annotations, as well as the occasional use of `@ConfigurationProperties` and `@Value` annotations, as well as the occasional use of
`RelaxedPropertyResolver`. `Binder`.
......
...@@ -1100,15 +1100,40 @@ The following properties names can all be used: ...@@ -1100,15 +1100,40 @@ The following properties names can all be used:
|Standard camel case syntax. |Standard camel case syntax.
|`person.first-name` |`person.first-name`
|Dashed notation, recommended for use in `.properties` and `.yml` files. |Kebab-case, recommended for use in `.properties` and `.yml` files.
|`person.first_name` |`person.first_name`
|Underscore notation, alternative format for use in `.properties` and `.yml` files. |Underscore notation, alternative format for use in `.properties` and `.yml` files.
|`PERSON_FIRST_NAME` |`PERSON_FIRSTNAME`
|Upper case format. Recommended when using a system environment variables. |Upper case format. Recommended when using a system environment variables.
|=== |===
NOTE: The `prefix` value for the annotation must be in kebab-case, ie, lowercase and separated by `-`.
.relaxed binding rules per property source
[cols="2,4,4"]
|===
| Property Source | Simple | List
|Properties Files
|Camel-case, kebab-case or underscore notation
|Standard list syntax using `[ ]` or comma-separated values
|YAML Files
|Camel-case, kebab-case or underscore notation
|Standard YAML list syntax or comma-separated values
|Environment Variables
|Upper case format with underscore as the delimiter. `_` should not be used within a property name
|Numeric values surrounded by underscores. eg: `MY_FOO_1_BAR = my.foo[1].bar`
|System properties
|Camel-case, kebab-case or underscore notation
|Standard list syntax using `[ ]` or comma-separated values
|===
TIP: We recommend that, when possible, properties are stored in lowercase kebab format. i.e. `my.property-name=foo`
[[boot-features-external-config-conversion]] [[boot-features-external-config-conversion]]
...@@ -1671,9 +1696,8 @@ use the `defaultValue` attribute. ...@@ -1671,9 +1696,8 @@ use the `defaultValue` attribute.
</appender> </appender>
---- ----
TIP: The `RelaxedPropertyResolver` is used to access `Environment` properties. If specify NOTE: The `source` must be specified using kebab-case (`my.property-name`). However, properties can be added to the
the `source` in dashed notation (`my-property-name`) all the relaxed variations will be `Environment` using the relaxed rules.
tried (`myPropertyName`, `MY_PROPERTY_NAME` etc).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment