- I created a demo app
- In
application.yml
, I usetest.longName
to bind the property toTestProperties
- then, I use
Binder
to change the new value forTestProperties
use key:test.long-name
, and it works, the new bean ofTestProperties
has a new value oflongName
- BUT, the question is, HOW to make
environment.getProperty("test.long-name")
equals toenvironment.getProperty("test.longName")
- Does spring boot has some magic for all relax naming properties change to a same value?
step to reproduce
- just run the DemoApplication demo.zip
Comment From: snicoll
@xinkunZ you shouldn't mutate the Environment
that way once the application is running. If you do that in an EnvironmentPostProcessor
, relaxed binding will work transparently. ConfigurationPropertySources#attach
is the process of putting a PropertySource
in front that knows about relaxed binding. If you mutate the environment manually, you'll have to take care of that too if you remove a PropertySource
completely.
If you have more questions, please ask on StackOverflow, as mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.