Forwarding error Load balancer does not have available server for client: api

遇到这样的错误:
com.netflix.zuul.exception.ZuulException: Forwarding error
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:
    at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:163) 
    at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:111) ~
    at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.ja
    at org.springframework.cloud.netflix.zuul.web.ZuulController.handleRequest(ZuulController.java:44) [spring-
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_151]
Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: api
    at com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483) ~[ribbon-loadbalancer-2.2.2.jar:2.2.2]

####这是因为你省略了这个依赖:


<dependency>
    <groupId>org.springframework.cloudgroupId>
    <artifactId>spring-cloud-starter-eurekaartifactId>
dependency>

zuul服务器要读取eureka注册的微服务,必须自己也要作为eureka的客户端,所以必定要配置eureka依赖。

写在最后:

加wx,获得更多关于Spring Cloud高级视频

Forwarding error Load balancer does not have available server for client: api_第1张图片

你可能感兴趣的:(spring,cloud,笔记)