• I created a demo app
  • In application.yml, I use test.longName to bind the property to TestProperties
  • then, I use Binder to change the new value for TestProperties use key:test.long-name , and it works, the new bean of TestProperties has a new value of longName
  • BUT, the question is, HOW to make environment.getProperty("test.long-name") equals to environment.getProperty("test.longName")
  • Does spring boot has some magic for all relax naming properties change to a same value?

step to reproduce

  1. 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.