spring-boot - 带有密钥 URL 的 Spring Boot YAML 配置不再使用版本 2 正确加载
问题描述
我正在将我的应用程序从 Spring Boot 1.5 迁移到 2.0,并且 YAML 属性之一不再正确加载。以下配置片段:
myapp
serviceUrls:
'https://example.org/test': 'https://test.example.org/Endpoint'
映射到这个配置类:
@ConfigurationProperties(prefix = "myapp", ignoreUnknownFields = false)
public final class MyAppProperties {
private Map<String, String> serviceUrls = new HashMap<>();
//[...]
}
- 在 Spring Boot 1.5 中,它加载为带有
https://example.org/test
->的地图https://test.example.org/Endpoint
; - 但是在 Spring Boot 2.0 中,冒号和斜杠从映射键
httpsexample.orgtest
->中消失了https://test.example.org/Endpoint
。
我在迁移指南中找不到任何提及。Spring Boot 2 中的 YAML 解析是否发生了变化?有没有更好的方法来编写以 URL 作为键的 YAML 映射?
解决方案
推荐阅读
- php - Laravel 8:让 CSS 在 https 和 http 上都加载?(现在使用 AWS)
- makefile - 如何使用make为每个文件调用命令?
- python - Django以访客身份添加到购物车而无需登录
- jquery - 为什么这个 JQuery 脚本不再在我的 https 服务器上运行?
- c# - 按顺序将两个int的数组组合成一个数组不起作用
- discord.py - 如何删除每个带有事件的文本频道?
- spring-boot - Spring Boot 测试未到达 MySql 数据库
- time-complexity - 固定循环的大 O
- vue.js - 在 vuejs 顶部显示最近添加的记录
- python - 在 Python 中建立 HTTPS 连接时出现 HTTP 400 错误请求?