Spring boot 键中带有URL的Spring Boot YAML配置在版本2中不再正确加载

Spring boot 键中带有URL的Spring Boot YAML配置在版本2中不再正确加载,spring-boot,yaml,snakeyaml,Spring Boot,Yaml,Snakeyaml,我正在将我的应用程序从Spring Boot 1.5迁移到2.0,其中一个YAML属性不再正确加载。以下配置代码段: myapp 服务URL: 'https://example.org/test': 'https://test.example.org/Endpoint' 映射到此配置类: @ConfigurationProperties(prefix=“myapp”,ignoreUnknownFields=false) 公共最终类MyAppProperties{ 私有映射服务URL=newHa

我正在将我的应用程序从Spring Boot 1.5迁移到2.0,其中一个YAML属性不再正确加载。以下配置代码段:

myapp
服务URL:
'https://example.org/test': 'https://test.example.org/Endpoint'
映射到此配置类:

@ConfigurationProperties(prefix=“myapp”,ignoreUnknownFields=false)
公共最终类MyAppProperties{
私有映射服务URL=newHashMap();
//[...]
}
  • 在Spring Boot 1.5中,它作为映射加载
    https://example.org/test
    ->
    https://test.example.org/Endpoint
  • 但是在SpringBoot2.0中,冒号和斜杠从映射键中消失
    httpsexample.orgtest
    ->
    https://test.example.org/Endpoint

我在报纸上找不到这方面的任何提及。在SpringBoot2中YAML解析是否发生了变化?有没有更好的方法来编写以URL作为键的YAML映射?

我应该检查一下GitHub问题。。。有人报告了。解决方案是使用“括号语法”,不幸的是,它将键包装在括号内:

myapp
  serviceUrls:
    '[https://example.org/test]': 'https://test.example.org/Endpoint'

你试过双引号还是反斜杠?YAML语法有时令人惊讶。@KonstantinPelepelin是的,我两个都试过了,但我的钥匙还是被弄坏了。更奇怪的是,输入到
org.yaml.snakeyaml.yaml#load
的同一个字符串确实产生了预期的结果。。。