使用ribbon测试调用eureka注册中心的服务时报错 No instances available for COMPUTE-SERVICE] with root cause解决 记录一次自己使用ribbon遇到的问题 可以看到服务生产者和消费者已经注册到了eureka注册中心
访问ribbon地址(例如:http://localhost:3333/add)时浏览器却出现该类报错。 查看程序控制台报错如下: 2021-08-06 23:39:37.865 ERROR 9488 — [nio-3333-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: No instances available for COMPUTE-SERVICE] with root cause
java.lang.IllegalStateException: No instances available for COMPUTE-SERVICE at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(RibbonLoadBalancerClient.java:119) ~[spring-cloud-netflix-ribbon-2.2.9.RELEASE.jar:2.2.9.RELEASE] at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(RibbonLoadBalancerClient.java:99) ~[spring-cloud-netflix-ribbon-2.2.9.RELEASE.jar:2.2.9.RELEASE] at org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor.intercept(LoadBalancerInterceptor.java:56) ~[spring-cloud-commons-3.0.3.jar:3.0.3] at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:93) ~[spring-web-5.3.9.jar:5.3.9] at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:77) ~[spring-web-5.3.9.jar:5.3.9] at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-5.3.9.jar:5.3.9]
后面经过排查可以确定是导入包冲突 在排查过程中发现ribbon的包和eureka-server的包有冲突,实际eureka-server已经包含ribbon,所以只需要把ribbon去除即可。 访问成功
|