【发布时间】:2018-12-15 11:28:57
【问题描述】:
我有一个设置,我正在使用以下内容:
- 带有 Spring Cloud 版本 Edgware.S3 的 Spring Boot 1.5.13
- 我有 Spring Cloud Config Server,我的 Spring Boot 应用程序是它的客户端
- 每个应用都带有一个带有配置服务器 uri 和其他一些属性的 bootstrap.yml。
- 在 Docker Swarm 上运行容器
我目前正在通过自定义脚本将 Swarm 机密传递给客户端,该脚本读取放入 /run/secrets/ 的文件并创建 /config/bootstrap.properties 文件。它最终看起来像这样:
spring.cloud.config.username=user
spring.cloud.config.password=password
我的 Docker 镜像的默认命令是这样的:
java -Djava.security.egd=file:/dev/./urandom -jar /${appName}.jar --spring.cloud.bootstrap.location=file:/config/bootstrap.properties"
太好了。这工作没有问题。该应用程序似乎是这样写的:
- 用于读取配置服务器凭据的外部 bootstrap.properties
- 类路径 bootstrap.yml 用于读取配置客户端道具的其余部分
- 获取并读取配置服务器的 application-appName.yml
- 然后从类路径中读取捆绑的 application.yml
现在。我正在使用 Finchley.RELEASE 将应用程序移至 Spring Boot 2.0.3,这会中断。
现在发生的事情是:
- 读取外部 bootstrap.properties 以获取配置服务器的凭据
- 类路径 bootstrap.yml 被完全跳过(意外!)
- 获取并读取配置服务器的 application-appName.yml
- 然后从类路径中读取捆绑的 application.yml
问题是应用程序现在缺少在内部 bootstrap.yml 中设置的属性,因此它在启动时会爆炸。通过做同样的事情,我已经能够在容器环境之外重现它;将应用程序指向外部 bootstrap.properties。如果我将 bootstrap.yml 属性复制到 bootstrap.properties 中,那么它就可以正常工作。此外,如果我不提供外部属性文件,那么内部 bootstrap.yml 将毫无问题地启动。所以它要么是一个,要么是另一个!
我也尝试修改引导位置以包含默认位置,但没有运气:
-- spring.cloud.bootstrap.location=file:/config/bootstrap.properties,classpath:,classpath:/config,file:,file:config/
有什么想法可以看下一步吗?也许我缺少一个新的 spring.cloud.config 属性?或者任何人都可以确认哪种行为是正确的行为?假设他们修复了 Finchley 中的一个潜在漏洞,那么我可以搁置它并寻找另一个解决方案。如果它在 Finchley 中“损坏”了,我猜应该有问题报告吧?
【问题讨论】:
标签: spring-boot properties-file spring-cloud-config