小编Miz*_*o10的帖子

使用本地属性覆盖远程 Spring Cloud 属性

我有一个 Spring Boot 应用程序,它通过 Spring Cloud 从远程配置服务器读取属性,并且它可以与远程存储库中定义的不同配置文件配合使用,我使用以下命令运行它:

java -jar my-app.jar --spring.profiles.active=my-custom-profile
Run Code Online (Sandbox Code Playgroud)

但是,在某些特殊情况下,我希望能够在更改某些远程属性的同时运行应用程序(这些更改不是固定的,因此我无法为它们创建一些自定义配置文件),因此我尝试覆盖直接通过命令行进行操作:

java -jar my-app.jar --spring.profiles.active=my-custom-profile --my.first.property=value1 --my.second.property=value2
Run Code Online (Sandbox Code Playgroud)

但似乎没有考虑到这一点,因为应用程序在启动时仍然采用远程属性。

有没有适当的方法来实现这一目标?

java spring spring-boot spring-cloud spring-cloud-config

3
推荐指数
1
解决办法
1442
查看次数