4

我有一个在端口 8761 (localhost:8761/eureka) 上运行的 Eureka 服务器,并且我有一个想在 eureka 注册的 Zuul 应用程序,但我一直收到同样的错误:

Can't get a response from http://localhost:8761/eurekaapps/ZUULSERVER
Can't contact any eureka nodes - possibly a security group issue?

java.lang.RuntimeException: Bad status: 404
        at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1155)
        at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1060)
        at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:606)
        at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1596)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

这是我的 zuul 应用程序的 application.yml:

info:
  component: Zuul Server

eureka:
  server:
    enabled: true
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka
    registerWithEureka: true
    fetchRegistry: false  

endpoints:
  restart:
    enabled: true
  shutdown:
    enabled: true
  health:
    sensitive: false

zuul:
  route:
    discovery:
      url: http://localhost:9000/polaris/discovery 
      path: /polaris/discovery/**
    sla:
      url: http://localhost:9000/polaris/sla
      path: /polaris/sla/**
    stores: /stores/**
    customers: /customers/**

#remove when spring-boot 1.2.1 is out
security:
  basic:
    enabled: false
management:
  security:
    enabled:
      false

server:
  port: 8765

logging:
  level:
    ROOT: INFO
    org.springframework.web: DEBUG

我是否只是弄乱了这些值之一,因此 zuul 无法看到尤里卡服务器?好像没有正确注册。也许我错过了 application.yml 文件中的一个关键参数?

4

1 回答 1

10

线索是错误中的“eurekaapps”。您需要在服务 URL 中使用尾随“/”:

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

(无论如何我认为这是默认设置)。

于 2014-12-19T16:07:40.800 回答