使用 Cloud Config Server 时的 Spring Boot 外部配置顺序? [英] Spring Boot external configuration order when using Cloud Config Server?

查看:31
本文介绍了使用 Cloud Config Server 时的 Spring Boot 外部配置顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用 Spring Cloud Config,并希望为客户端提供一种覆盖来自 cofnig 服务器的属性的方法.但是,在阅读 https://之后/docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html,应用云配置时不明显.

I'm starting to use Spring Cloud Config and would like to give a way for clients to override properties that come from cofnig server. However, after reading https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html, it isn't apparent when the Cloud Configuration applies.

我还阅读了 http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html 并且它谈到了覆盖.但它们似乎与我想要的相反(这些覆盖用于覆盖客户端提供的属性).

I've also read http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html and it talks about overrides. But they seem to be the opposite of what I want (those overrides are for overriding the client provided properties).

那么,Cloud Config 在哪里适合排序?我还能在类路径上提供一个本地 application.properties 文件来覆盖某些 Cloud Config 属性吗?

So, where does the Cloud Config fit in the ordering? Would I still be able to give a local application.properties file on the classpath to override certain Cloud Config properties?

推荐答案

git commit/push 过程是过程的一部分,实际上……Spring Cloud Config 使用 git 来处理配置文件、更改、审计等.,因为 git 非常适合于此,&Config 充分利用了这些优势.

The git commit/push process is part of the process, actually...Spring Cloud Config uses git to handle the config files, changes, auditing, etc., as git is ideally suited for that, & Config leverages those strengths.

如果您只是在寻找一种加快配置更改测试的方法并愿意接受权衡,您可以使用本地(或本地网络)存储库作为您的配置存储库进行测试.我意识到这不是您特别要问的,但假设您使用配置服务器应用程序的 application.properties 指向底层 git repo,这是一个可能有帮助的选项.如果是这样,您可以像这样在命令行上覆盖 spring.cloud.config.server.git.uri:

If you're just looking for a way to expedite testing of config changes and are willing to accept the tradeoffs, you can use a local (or local network) repo for your config repository for testing. I realize this isn't what you're asking specifically, but it's an option that may help, assuming you're using the Config server app's application.properties to point to the underlying git repo. If so, you can override spring.cloud.config.server.git.uri on the command line like so:

java -Dspring.cloud.config.server.git.uri=${HOME}/testing/config-repo -jar your_jar_here.jar

java -Dspring.cloud.config.server.git.uri=${HOME}/testing/config-repo -jar your_jar_here.jar

这将允许您调整从配置服务器获取其设置的客户端应用程序/服务的配置设置,而不会影响生产配置文件(甚至分支).

This will allow you to tweak the config settings for client apps/services that obtain their settings from the Config server without affecting the production config files (even branches).

我希望这会有所帮助.如果没有,或者如果我误解了您的目标或约束,请澄清(如果您可以分享它们,一两个用例可能会帮助我更好地进行三角测量),我会再试一次.:)

I hope this helps. If not, or if I've misunderstood your goals or constraints, please clarify (a use case or two might help me triangulate better, if you can share them) and I'll take another run at it. :)

干杯,标记

这篇关于使用 Cloud Config Server 时的 Spring Boot 外部配置顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆