To use some special characters in a key of a property in a YAML file (like
application.yml) processed by Spring Boot 2.0 (or later) you need to use specific syntax. Key element containing “/” or “@” or “+” (and possibly some other special characters) needs to be surrounded by square brackets. Example:
foo.bar: "[http://something]": value
This is needed to define property named
"foo.bar.http://something" in Spring Boot 2.0 or later. According to Spring Boot issue #13404 (Allow map binding to work with unescaped characters) it was not needed in Spring Boot 1.5 (and most likely in earlier versions).
If you don’t use square brackets in such a case when using Spring Boot 2.0 or later the actual property name will be different causing things like value injection (
@Value annotation) to not work.
Another Spring Boot issue, #14017 (Property binder does not allow special characters in map keys), explains that with Spring Boot 2.0 (or later) special characters are dropped silently when square brackets are not used.
It seems this feature was not document well for some time – see Spring Boot issue #13506 (Document when and how to use bracket notation when binding to a map).
I’m not claiming it is a good idea to use such characters as “/”, “@” or “+” in property keys with Spring Boot. I recommend to avoid such design decisions as it may make it really hard to override properties using for example environment variables.