我正在尝试将 Eureka 设置为使用云配置服务器,但 Eureka 服务器在启动时无法找到 configserver 的实例:
WARN 17584 --- [ main] lientConfigServiceBootstrapConfiguration : No instances found of configserver (CONFIGSERVER)
不确定我在配置方面缺少什么。配置服务器如下:
引导程序.yml
spring:
application:
name: configserver
应用程序.yml
spring:
profiles: dev
cloud:
config:
server:
git:
uri: https://XXXXXXX/config.git
username: XXXXXXX
password: XXXXXXX
server:
port: 9999
eureka:
instance:
hostname: localhost
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:9998/eureka/
从配置为 bootstrap.yml (1) 的发现服务开始。似乎当 configserver 注册时,发现服务应该能够检索其配置并正确启动,但发现服务无法完全启动并且配置服务器永远无法注册。当我在 bootstrap.yml (2) 中添加附加配置时,两个服务都会启动,但发现服务从不使用配置服务器来检索其配置 (discoveryservice.yml)。如果我提供 spring.cloud.config.uri 属性,发现服务将启动并按预期从服务器检索其配置。让我觉得我遗漏了一些东西,或者 Eureka 在没有配置服务器 uri 的情况下无法从配置服务器检索其配置?
bootstrap.yml (1)
spring:
application:
name: discoveryservice
---
spring:
profiles: dev
cloud:
config:
discovery:
enabled: true
bootstrap.yml (2)
spring:
application:
name: discoveryservice
---
spring:
profiles: dev
cloud:
config:
discovery:
enabled: true
server:
port: 9998
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
discoveryservice.yml(来自配置服务器 git repo):
server:
port: 9998
---
spring:
profiles: dev
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/