【发布时间】:2018-08-14 08:38:19
【问题描述】:
我有关于在配置服务器的共享文件中解析环境变量的问题。 我目前的设置非常小:
-
src/main/resources/shared/application.yml:
应用: 版本:0.0.1-早期 测试:${JAVA_HOME}
-
src/main/resources/application.properties:
spring.profiles.active=native spring.cloud.config.server.native.searchLocations=classpath:/shared
-
使用 gradle :
- spring-boot-gradle-plugin:2.0.0.RELEASE
- spring-cloud-dependencies:Camden.SR7
- 然后当然在 deps 中编译 'org.springframework.cloud:spring-cloud-config-server'
问题: GET http://localhost:8888/apptest/application 给我:
{
"name": "apptest",
"profiles": [
"application"
],
"label": null,
"version": null,
"state": null,
"propertySources": [
{
"name": "classpath:/shared/application.yml",
"source": {
"application.version": "0.0.1-early",
"application.test": "${JAVA_HOME}"
}
}
]
}
所以 env 变量没有被解析。同样的事情是:
- http://localhost:8888/apptest/application?resolvePlaceholders=true
- http://localhost:8888/lab/apptest-application.properties?resolvePlaceholders=true
- http://localhost:8888/lab/apptest-application.properties?resolvePlaceholders=false
- http://localhost:8888/apptest-application.properties?resolvePlaceholders=true
我查看了Spring cloud config server. Environment variables in properties,但解决方案对我没有帮助 + 从那时起那里很少有新版本。所以我要提出新问题。
【问题讨论】:
标签: java spring-cloud spring-cloud-config spring-config