Property key with square bracket is not support. Config server responses with HTTP error code 400, "error": "Bad Request". But such properties is supported by Spring Boot.
Spring Boot documentation https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding
For YAML files, the brackets need to be surrounded by quotes for the key to be parsed properly.
foo:
nested:
"[bar.baz]":
bling: 2
Or another documentation: https://docs.spring.io/spring-boot/docs/2.7.6/reference/pdf/spring-boot-reference.pdf s. 96
For example, consider binding the following properties to a Map<String,String>:
Yaml
my:
map:
"[/key1]": "value1"
"[/key2]": "value2"
"/key3": "value3"
NOTE
For YAML files, the brackets need to be surrounded by quotes for the keys to be
parsed properly.
The properties above will bind to a Map with /key1, /key2 and key3 as the keys in the map. The slash
has been removed from key3 because it was not surrounded by square brackets.
Sample Config file: example.yml
foo:
nested:
"[bar.baz]":
bling: 2
my:
map:
"[/key1]": "value1"
"[/key2]": "value2"
"/key3": "value3"
curl localhost:8888/example-default.yml
400 error code is returned
Comment From: woshikid
As in my test with config file:
my:
map:
"[/key1]": "value1"
"[/key2]": "value2"
"/key3": "value3"
curl localhost:8888/example/default
works fine
curl localhost:8888/example-default.yml
500 errors (class java.util.LinkedHashMap cannot be cast to class java.util.List)