Reputation: 10892
Setting an environment variable
MYAPP_MYMAP_CaseSensitive=foo
for a Map property of Spring Boot's (2.1.7.RELEASE) @ConfigurationProperties
@ConfigurationProperties(prefix = "myapp")
class MyProperties {
private Map<String, String> myMap;
// getters, setters...
}
loads the Map with keys in lowercase:
{casesensitive=foo}
So far I found a workaround using SPRING_APPLICATION_JSON
:
SPRING_APPLICATION_JSON={"myapp.myMap":{"CaseSensitive":"foo"}}
Is there a correct way to set case-sensitive keys via environment variables?
Upvotes: 1
Views: 3199
Reputation: 116211
No, it can't at the moment. This is something we'd like to improve in the future. That improvement is being tracked by this issue.
In the meantime, if you want to provide the configuration via an environment variable then using SPRING_APPLICATION_JSON
is the recommended approach.
Upvotes: 1