@@ -600,13 +600,38 @@ in a similar manner as the `ConnectionSettings` example above.
600
600
Spring Boot uses some relaxed rules for binding `Environment` properties to
601
601
`@ConfigurationProperties` beans, so there doesn't need to be an exact match between
602
602
the `Environment` property name and the bean property name. Common examples where this
603
- is useful include underscore separated (e.g. `context_path ` binds to `contextPath`), and
603
+ is useful include dashed separated (e.g. `context-path ` binds to `contextPath`), and
604
604
capitalized (e.g. `PORT` binds to `port`) environment properties.
605
605
606
- NOTE: Environment variables are usually underscore-separated and upper case. You can
607
- use that format and Spring Boot will bind them to your bean property names accordingly.
608
- For instance `MY_PROPERTY` will match just the same as `myProperty`, `my_property` or
609
- `my-property`.
606
+ For example, given the following `@ConfigurationProperties` class:
607
+
608
+ [source,java,indent=0]
609
+ ----
610
+ @Component
611
+ @ConfigurationProperties(prefix="person")
612
+ public class ConnectionSettings {
613
+
614
+ private String firstName;
615
+
616
+ }
617
+ ----
618
+
619
+ The following properties names can all be used:
620
+
621
+ .relaxed binding
622
+ [cols="1,4"]
623
+ |===
624
+ | Property | Note
625
+
626
+ |`person.firstName`
627
+ |Standard camel case syntax.
628
+
629
+ |`person.first-name`
630
+ |Dashed notation, recommended for use in `.properties` and `.yml` files.
631
+
632
+ |`PERSON_FIRST_NAME`
633
+ |Upper case format. Recommended when using a system environment variables.
634
+ |===
610
635
611
636
Spring will attempt to coerce the external application properties to the right type when
612
637
it binds to the `@ConfigurationProperties` beans. If you need custom type conversion you
0 commit comments