java - 如何在春季重用.conf文件中的配置值
问题描述
我conf
在我的 spring 项目中使用文件作为配置文件。在该文件下,值定义为
dev {
notification {
cms {
endpointPrefix: "https://example.com/notification"
}
}
cms {
url: "https://example.com"
service {
url: "https://example.com/hello"
timeout: 5000
}
}
appConfig {
url: "https://example.com/values/app"
refreshFrequencyInMins: 30
}
}
现在我想https://example.com
用一些共同的值替换所有的用法,这样我就不需要多次定义同一个域,而且每当我需要更新它时,我几乎不需要改变。我确实尝试过这样
dev {
cms_url: "https://example.com"
notification {
cms {
endpointPrefix: "${cms_url}/notification"
}
}
cms {
url: "${cms_url}"
service {
url: "${cms_url}/hello"
timeout: 5000
}
}
appConfig {
url: "${cms_url}/values/app"
refreshFrequencyInMins: 30
}
}
但它不起作用,所以想了解几件事
- 我需要用 替换
cms_url
吗dev.cms_url
? - conf文件中的变量替换如何工作?
- 它是从根路径还是从相对路径检查变量,然后转到上层,直到变量不存在?
notification
是之前定义的,cms
所以如果我想在中使用“cms.url”notification.cms.endpointPrefix
,它会起作用还是顺序问题?
解决方案
推荐阅读
- synchronization - ADFS 组与 nextcloud 同步
- reactjs - 输入字段 Onchange 不允许输入
- x86 - x86 指令的时序有多少差异?
- android - Spinner Itemselected Listner 在使用自定义 Adpater 时未触发(来自 api Json 的数据)
- vue.js - 在表格antDesign Vuejs中添加输入
- graphql - 我可以将 useSWR 与 apollo-client 一起使用吗?
- angular - 我如何将代码 html 转换为文本并将其保存在关系 Bd 中
- php - 复选框值 id 没有得到
- android - 应用程序启动后加载 Koin 模块 - 运行时异常
- python - 使用 functools.partial 的 Python 装饰器。“func”从何而来?