From 05e402295d22c2fbbf3371b642d3a752e449dc13 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sat, 27 Dec 2014 18:28:13 +0100 Subject: [PATCH] Mention environment variables mapping in the guide Closes gh-2234 --- .../src/main/asciidoc/spring-boot-features.adoc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 68b7f5aa14..232de38510 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -543,13 +543,18 @@ definitions by simply listing the properties classes directly in the [[boot-features-external-config-relaxed-binding]] -==== Relaxed binding +==== Relaxed binding (Properties format) Spring Boot uses some relaxed rules for binding `Environment` properties to `@ConfigurationProperties` beans, so there doesn't need to be an exact match between the `Environment` property name and the bean property name. Common examples where this is useful include underscore separated (e.g. `context_path` binds to `contextPath`), and capitalized (e.g. `PORT` binds to `port`) environment properties. +NOTE: Environment variables are usually underscore-separated and upper case so you can +just use that and Spring Boot will bind it to your bean property names accordingly. For +instance `MY_PROPERTY` will match just the same as `myProperty`, `my_property` or +`my-property`. + Spring will attempt to coerce the external application properties to the right type when it binds to the `@ConfigurationProperties` beans. If you need custom type conversion you can provide a `ConversionService` bean (with bean id `conversionService`) or custom