【发布时间】:2016-07-21 13:41:31
【问题描述】:
我开始使用 Spring Cloud Config,并希望为客户端提供一种方法来覆盖来自 cofnig 服务器的属性。但是,在阅读https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html 之后,云配置何时适用并不明显。
我还阅读了http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html,它谈到了覆盖。但它们似乎与我想要的相反(这些覆盖是为了覆盖客户端提供的属性)。
那么,Cloud Config 在排序中的位置是什么?我仍然可以在类路径上提供一个本地 application.properties 文件来覆盖某些 Cloud Config 属性吗?
【问题讨论】:
-
配置服务器应用在最顶层。如果您希望应用程序覆盖某些内容,为什么不在配置服务器中提供特定于应用程序的配置?我对你的用例有点困惑。
-
查看
/env执行器端点。它将向您显示应用程序中使用的属性源,以及它们相互覆盖的顺序(之前列出的源会覆盖后来列出的源)。一般情况下,ConfigServer 源很早,仅在默认排序中的命令行 -D 属性之后。 -
在测试应用程序时,通过 git 分支、推送和审查配置更改过程的开销太大。测试人员更喜欢一种无需通过 git 进程即可进行本地更改的方法。
-
你确定Spring Boot Actuator中的
/env是按配置顺序排列的吗?对我来说,这似乎只是按字母顺序排列的。在我的示例中,defaultProperties显示 afterconfigService,这是不正确的排序。 -
@AndyShinn:你有什么东西要重新排序吗?当我点击端点时,我看到它们按以下顺序列出 1.profiles 2.configService:myrepo.git/application.properties 3.servletContextInitParams 4.systemProperties 5.systemEnvironment 6.applicationConfig:classpath:/application.properties 7.defaultProperties
标签: spring-boot spring-cloud spring-cloud-config