[英]Configure spring cloud config server for each profile group
我的環境很少。 有:
如果配置服務器連接到所有服務器,則一切都會清除。
就我而言,我需要每個組的配置服務器:
組連接到權限和不同的環境。
所以我需要每個客戶類似的東西:
bootstrap.yml
# default configs for local, dev, test profiles
spring:
application:
name: discovery-service
cloud:
config:
uri: http://local-dev-test-configuration-server:8888
---
# **bootstrap-qa.yml**
spring:
profiles: qa
application:
name: discovery-service
cloud:
config:
uri: http://qa-configuration-server:8888
---
# **bootstrap-prod.yml**
spring:
profiles: prod,lod
application:
name: discovery-service
cloud:
config:
uri: http://lod-prod-configuration-server:8888
哪里
local-dev-test-configuration-server
可以訪問local
, dev
和test
服務器配置; qa-configuration-server
將有權訪問qa
配置; lod-prod-configuration-server
將只能訪問prod
和lod
配置。 我研究了Spring Boot文檔,但沒有遇到bootstrap.yml
分析。
有兩種可能的解決方案來為spring-cloud-configuration-server配置客戶端:
bootstrap.yml
配置文件,因此有問題的配置可以用作解決方案 spring:
application:
name: discovery-service
cloud:
config:
uri: http://local-dev-test-configuration-server:8888
---
spring:
profiles: qa
application:
name: discovery-service
cloud:
config:
uri: http://qa-configuration-server:8888
---
spring:
profiles: prod,lod
application:
name: discovery-service
cloud:
config:
uri: http://lod-prod-configuration-server:8888
bootstrap.yml
配置盡可能簡單: spring:
application:
name: discovery-service
cloud:
config:
uri: http://local-dev-test-configuration-server:8888
在這種情況下,解決方案是使用-Dspring.cloud.config.uri=http://localhost:8888
參數覆蓋必需的屬性,例如:
java -Dspring.profiles.active=localhost -Dspring.cloud.config.uri=http://localhost:8888 -jar ./target/discovery-service-0.0.1-SNAPSHOT.jar
方法可以混合。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.