在与Zuul和Eureka一起路由时我正面对着ZuulException: forward error
。
在第一分钟内没有发生错误,但是在1或2分钟之后我得到了这个奇怪的错误。
我正在使用spring boot 1.4和spring cloud Camden
如果您想重现错误或看到我的项目:https://github.com/Seb69/Spring-demo-ZuulException/tree/master
尤里卡配置:
server:
port: 9999
spring:
application:
name: eureka-server
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
服务网关配置(Zuul):
server:
port: 1111
spring:
application:
name: service-gateway
# ZUUL (Load balancing)
zuul:
ignoredServices: '*'
routes:
service-server:
stripPrefix: true
path: /api/**
serviceId: SERVICE-SERVER
# EUREKA (Service registry)
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://localhost:9999/eureka/
服务配置:
server:
port: 8095
spring:
application:
name: service-server
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://localhost:9999/eureka/
这是我的堆栈跟踪的简短版本:
com.netflix.zuul.exception.ZuulException:转发错误
引起:com.netflix.client.ClientException:下次服务器上的重试次数超过最多1次重试,同时调用:mbp-de-andre:8095
引起:java.net.UnknownHostException:mbp-de-andre
FIX:所以,我终于成功了!
我的问题来自我的Macbook主机名,
最后的主机名是:mbp-de-andre
我修改它并设置:`MacBook-Pro-de-ANDRE.local``
只是想说另一个修复可能缺少依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>