【问题标题】:How to connect Config Client to Config server using Eureka server?如何使用 Eureka 服务器将 Config Client 连接到 Config 服务器?
【发布时间】:2020-12-30 15:01:49
【问题描述】:
我有一个场景,每当我们将 config server 与 config client 一起使用时,我们都需要放入 bootstrap.yaml。假设我的配置服务器在端口 9001 上,所以我需要在 http://localhost:9001:/
我的问题是,“可以使用 eureka server 将 config client 连接到 config server,这样我们就可以删除核心属性”
【问题讨论】:
标签:
spring-boot
spring-cloud
spring-cloud-config
spring-cloud-netflix
spring-boot-configuration
【解决方案1】:
这些是我使用的属性,解决了我的问题
Eureka 属性
spring.application.name=discovery-server
eureka.client.registerWithEureka = true
eureka.client.fetchRegistry = false
server.port = 9050
eureka.client.serviceUrl.defaultZone=http://localhost:9050/eureka/
配置服务器属性
spring:
application:
name: configserver
cloud:
config:
server:
git:
uri: git-url
username: git-username
password: git-password
fail-fast: true
server:
port: 8080
eureka:
client:
serviceUrl:
defaultZone: http://localhost:9050/eureka
配置客户端属性
spring:
application:
name: x
cloud:
config:
profile: dev
fail-fast: true
discovery:
enabled: true
service-id: CONFIGSERVER
retry:
initial-interval: 2000
multiplier: 1.5
max-interval: 60000
max-attempts: 100
server:
port: 8081
eureka:
client:
serviceUrl:
defaultZone: http://localhost:9050/eureka
fetch-registry: true
instance:
lease-renewal-interval-in-seconds: 10