I've noticed an inconsistency in properties binding from an ENV variable and property defined in application.properties
Consider following example:
@ConfigurationProperties("com.test")
public class Props {
private Map<String, Map<String, String>> property;
}
application.properties <- binding works correctly
com.test.property.foo.bar=value
Environment variable <- binding fails
export COM_TEST_PROPERTY_CCC_DDD=VALUE
I would expect that the same binding behavior for an externalized configuration. Any idea how to resolve this issue using Spring Boot 1.5.2?
I am using Spring Boot 1.5.2, Linux Mint 18.1, Java 8 ("1.8.0_121") Demo application available: https://github.com/peterjurkovic/spring-boot-binding-demo
Comment From: dturanski
Looks like the same issue I reported as https://jira.spring.io/browse/SPR-15451
does this work? export SPRING_APPLICATION_JSON='{"com.test": {"property":{"foo": {"bar" : "value"} } } }'
Comment From: philwebb
The JSON is probably your only option with 1.5.x. We're reworking binding in Boot 2.0 to make things more consistent but unfortunately fixing inconsistencies like this in 1.5.x is very difficult.
Comment From: dturanski
@philwebb This is a great test case: compound prefix with nested maps. If 2.0 can bind this correctly it can likely handle anything.
Comment From: philwebb
@dturanski I'll make sure we add a unit test in the new code.
Comment From: mkucharek
I've just hit a similar issue with Eureka default zone with Spring Boot 2.0.0.M7 - it doesn't seem to correctly handle camel cases when binding map elements..
Comment From: snicoll
@mkucharek this issue is closed. If you believe you have found an issue, please create a minimal sample (without Spring Cloud) that we can run ourselves and create a separate issue.
Comment From: rujche
Sharing my knowledge here:
Problem same with this issue: https://github.com/spring-cloud/spring-cloud-netflix/issues/2541 I can't left comment in https://github.com/spring-cloud/spring-cloud-netflix/issues/2541, so I add comment here.
EUREKA_CLIENT_SERVICEURLcan bind toserviceUrlwhich type isMap<String, String>.- When
DEFAULTZONEbind toMap, the key value isdefaultzone, (zin lowercase)。 - When read
serviceUrl,the key isdefaultZone. (Zin upper case)
It's hard to fix this issue in Spring boot side, because when DEFAULTZONE map to the key in Map<String, String>, if we want to support all case, there are too much cases. DEFAULTZONE has 11 chars, it will have 2^11 cases.
What we can do is: When binding Map