Spring Cloud Config 双 bootstrap 文件行为

Spring Cloud Config dual bootstrap files behavior

我有一个使用以下设置的设置:

我目前正在通过自定义脚本将 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"

太棒了。这没有问题。该应用程序似乎显示为:

现在。我正在使用 Finchley.RELEASE 将应用程序移动到 Spring Boot 2.0.3 好吧,这会中断。

现在发生的事情是:

问题是应用程序在内部 bootstrap.yml 中设置的属性现在丢失了,因此它在启动时崩溃了。通过做同样的事情,我已经能够在容器环境之外重现它;将应用程序指向外部 bootstrap.properties。如果我将 bootstrap.yml 属性复制到 bootstrap.properties 中,那么它就可以正常工作。此外,如果我不提供外部属性文件,那么内部 bootstrap.yml 将毫无问题地启动。所以非此即彼!

我也试过修改 bootstrap 位置以包含默认位置,但没有成功:

-- spring.cloud.bootstrap.location=file:/config/bootstrap.properties,classpath:,classpath:/config,file:,file:config/

有什么下一步要看的想法吗?也许有一个新的 spring.cloud.config 属性 我不见了?或者任何人都可以确认哪种行为是正确的行为?假设他们修复了 Finchley 中的一个潜在漏洞,那么我就可以搁置它并寻找其他解决方案。如果它是芬奇利的 'broken',我想问题报告是有序的?

好吧,更多的挖掘表明这是新的行为:

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide

The behavior of the spring.config.location configuration has been fixed; it previously added a location to the list of default ones, now it replaces the default locations. If you were relying on the way it was handled previously, you should now use spring.config.additional-location instead.

它看起来不像是 Spring 云特定的,但我没有什么可失去的。 更改我的 java 命令以使用这个新的 属性 就成功了:

--spring.config.additional-location=file:/config/bootstrap.properties

谢谢。