Why is this method called when create my configure @ConfigurationProperties class
// {@link org.springframework.boot.context.properties.source.ConfigurationPropertyName#convertToOriginalForm}
private CharSequence convertToOriginalForm(CharSequence element) {
return convertElement(element, false,
(ch, i) -> ch == '_' || ElementsParser.isValidChar(Character.toLowerCase(ch), i));
}
This operation led to something I didn't expect
# my applciation.yml
config:
mapping:
/a: /
/b: /hello
// my configure class
@Data
@ConfigurationProperties(prefix = "config")
public class Config {
private final Map<String, String> mapping = new HashMap<>();
}
result: Config->mapping = {"a":"/", "b":"/hello"}
but i expect: Config ->mapping = {"/a":"/", "/b":"/hello"}
Comment From: wilkinsona
This behaviour is described in the documentation. When binding to a map, properties with special characters in their name must by wrapped in []
.
If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.