【发布时间】:2017-03-12 15:37:11
【问题描述】:
我正在学习Spring Cloud Config 项目功能。我想知道是否可以使用占位符进行特定于应用程序的配置?
例如:
我的 application.yml 文件:
server:
port: 8888
spring:
profiles:
active: native
cloud:
config:
server:
native:
search-locations: classpath:/config
config 文件夹包含一个 my-app.yml 文件:
key:
value: ${my.password}
服务器以 -Dmy.password=password 环境变量启动。对 /my-app/native url 的获取请求返回:
{
"name": "my-app",
"profiles": ["native"],
"label": null,
"version": null,
"state": null,
"propertySources": [{
"name": "classpath:/config/my-app.yml",
"source": {
"key.value": "${my.password}"
}
}]
}
placeholder 中的 env 属性没有评估就返回给客户端,有没有办法在向客户端发送响应之前评估该属性?
【问题讨论】:
标签: spring spring-boot spring-cloud spring-cloud-config