关于SpringBoot yaml key为中文时的问题
在使用@ConfigurationProperties 进行注入时,向注入一个类似于下方的参数
@ConfigurationPerproties("test")
class test {
List<Map<String,Dog>> dogs;
}
class Dog {
private String name;
private Integer id;
public void setName(String name) {
this.name = name;
}
public void setId(Integer id) {
this.id = id;
}
}
在配置的时候使用中文为key 总是会有问题 , 感觉有非常奇怪的错误 , 会显示无法转换类
后来看到使用 "[]"
将中文引起来就可以了, 引号与[] 都不可以少
test:
dogs:
- "[二楼]":
name: 123
id: 12
- we:
name: 345
id: 45
记录一下 , 防止忘掉, 找了大半天呢…