2

我正在运行 Spring Cloud Brixton SR3 - Spring Netflix Eureka、Spring Cloud Config 和 Discovery Client 应用程序。当客户端应用程序配置为

eureka.client.healthcheck.enabled=truespring.cloud.config.discovery.enabled=true

该应用程序启动时在 Eureka 注册,状态为“UNKNOWN”,并且永远不会更改为“UP”。如果这些标志中的任何一个设置为 false,则应用程序启动时注册为“UP”。

当两个标志都启用/为真时,我会看到这一系列日志记录:

2016-07-13 17:41:38.144  INFO 13180 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1468456898144, current=UP, previous=STARTING]
2016-07-13 17:41:38.144 DEBUG 13180 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator     : Executing on-demand update of local InstanceInfo
2016-07-13 17:41:38.144 DEBUG 13180 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator     : Canceling the latest scheduled update, it will be rescheduled at the end of on demand update
2016-07-13 17:41:38.145  INFO 13180 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1468456898145, current=UNKNOWN, previous=UP]

如何让应用注册为 UP 并启用/为真这两个标志?

引导程序.yml

spring:
  application:
    name: hello-brixton

# Spring Cloud Config
  cloud:
    config:
      name: hello-brixton
      discovery:
        enabled: true
        serviceId: config-service

eureka:
  client:
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
      defaultZone: ${SERVICE_REGISTRY_URL:http://localhost:8080/eureka/}
    healthcheck:
      enabled: true
4

1 回答 1

6

我知道这是很久以前问过的,但我遇到了同样的问题,这是唯一与我的问题直接匹配的问题。

我正在使用 Camden.SR2,如果您在参考文档中找到 Eureka's Health Checks 部分,您将看到以下警告:

eureka.client.healthcheck.enabled=true只能设置在 application.yml. 设置值 inbootstrap.yml会导致不良副作用,例如在 eureka 中注册UNKNOWN 状态。

这正是问题所在。如果您将属性的设置转移到application.yml文件中,它会按预期工作。

于 2016-11-27T19:10:44.220 回答