Eureka First Bootstrap - 除非eureka服务器具有配置服务器URI,否则无法正常工作

时间:2016-04-07 17:08:20

标签: spring-cloud spring-cloud-config

我试图让Eureka设置为使用云配置服务器,但Eureka服务器无法在启动时找到configserver的实例:

WARN 17584 --- [           main] lientConfigServiceBootstrapConfiguration : No instances found of configserver (CONFIGSERVER)

不确定我在配置方面缺少什么。配置服务器如下:

bootstrap.yml

spring:
  application:
    name: configserver

application.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/

0 个答案:

没有答案