Eureka error "java.net.UnknownHostException:
spring cloud 中zuul智能路由,本地部署没有问题,部署到服务器就报com.netflix.zuul.exception.ZuulException: Forwarding error
项目中用到spring cloud+docker,各个组件本地部署没有,一部署在服务器就出现问题,报如下的错误
com.netflix.zuul.exception.ZuulException: Forwarding error at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:189) ~[spring-cloud-netflix-zuul-2.0.0.RC1.jar!/:2.0.0.RC1] at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:164) ~[spring-cloud-netflix-zuul-2.0.0.RC1.jar!/:2.0.0.RC1] at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:112) ~[spring-cloud-netflix-zuul-2.0.0.RC1.jar!/:2.0.0.RC1] at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:117) ~[zuul-core-1.3.1.jar!/:1.3.1] at com.netflix.zuul.FilterProcessor.processZuulFilter(FilterProcessor.java:193) ~[zuul-core-1.3.1.jar!/:1.3.1] at com.netflix.zuul.FilterProcessor.runFilters(FilterProcessor.java:157) ~[zuul-core-1.3.1.jar!/:1.3.1] at com.netflix.zuul.FilterProcessor.route(FilterProcessor.java:118) ~[zuul-core-1.3.1.jar!/:1.3.1] at com.netflix.zuul.ZuulRunner.route(ZuulRunner.java:96) ~[zuul-core-1.3.1.jar!/:1.3.1] at com.netflix.zuul.http.ZuulServlet.route(ZuulServlet.java:116) ~[zuul-core-1.3.1.jar!/:1.3.1] at com.netflix.zuul.http.ZuulServlet.service(ZuulServlet.java:81) ~[zuul-core-1.3.1.jar!/:1.3.1]
从网上找各种资源都没找到,包括找springcloud 开源社区发帖
关键在于-----
在配置文件加入
eureka: client: serviceUrl: defaultZone: http://XXX:8080/eureka/ #这里才是关键 fetch-registry: true register-with-eureka: true
#服务注册中心实例的主机名 eureka.instance.hostname=localhost #是否向服务注册中心注册自己 eureka.client.register-with-eureka=true #是否检索服务 eureka.client.fetch-registry=true