相关疑难解决方法(0)

在Spring Boot中转义Yaml中的Map键中的一个点

我有一个以下的yml配置:

foo:
  bar.com:
    a: b
  baz.com:
    a: c
Run Code Online (Sandbox Code Playgroud)

使用以下类,Spring尝试使用键"bar"和"baz"注入地图,将点视为分隔符:

public class JavaBean {
    private Map<String, AnotherBean> foo;
(...)
}
Run Code Online (Sandbox Code Playgroud)

我试过引用密钥(即'bar.com'或"bar.com"),但无济于事 - 仍然是同样的问题.有没有解决的办法?

spring yaml key spring-boot

26
推荐指数
2
解决办法
1万
查看次数

标签 统计

key ×1

spring ×1

spring-boot ×1

yaml ×1