Springcloud:Zuul + Eureka无法正常工作

时间:2017-03-26 23:08:13

标签: spring-cloud netflix-eureka netflix-zuul

我花了一整天努力让Zuul + Eureka一起工作,但我对此并不幸运。只有Zuul,没有Eureka,工作得很好。我尝试过很多不同的配置,比如this one,它说我只需要在Eureka客户端中转Zull(在根应用程序类中使用@EnableDiscoveryClient)。

我的设置非常简单:它包含服务:8080 (服务1), Zuul:9000 Eureka:8761

当我尝试使用Zull(在这种情况下为http://localhost:9000/service1)尝试访问服务1时,我尝试使用Eureka的所有方法都给了我同样的错误:

com.netflix.zuul.exception.ZuulException: Forwarding error
(...)
com.netflix.client.ClientException: Load balancer does not have available server for client: service1

服务1工作正常(我可以直接从浏览器地址栏http://localhost:8080访问它),Eureka显示正确注册了Zull和Service 1:

enter image description here

应用程序配置如下:

服务1(bootstrap.yml):

spring:
  application:
    name: service1

服务1(application.yml):

eureka:
    instance:
        leaseRenewalIntervalInSeconds: 1
        leaseExpirationDurationInSeconds: 2
    client:
        serviceUrl:
            defaultZone: http://127.0.0.1:8761/eureka/

Zuul:

ribbon:
    eureka:
        enabled: false

eureka:
    instance:
        leaseRenewalIntervalInSeconds: 1
        leaseExpirationDurationInSeconds: 2
    client:
        serviceUrl:
            defaultZone: http://127.0.0.1:8761/eureka/
    healthcheck:
        enabled: true

server:
    port: 9000

尤里卡:

server:
  port: 8761

eureka:
  client:
    register-with-eureka: false
    fetch-registry: false

logging:
  level:
    com:
      netflix:
        eureka: OFF
        discovery: OFF

根应用程序类的Zuul注释:

@EnableZuulProxy
@EnableDiscoveryClient

我错过了重要的一点吗?

0 个答案:

没有答案