No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc

快速解决“No Feign Client for loadBalancing defined”的报错,让项目能够正常启动。但是还需要解决nacos和springcloud ribbon jar包不兼容的问题。引入下来依赖即可:

一、问题描述

        项目启动报错:Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?

翻译:“没有loadBalancing定义的feign客户端。你忘了包括加入spring-cloud-starter-loadbalancer了吗?”

二、解决IllegalStateException

        1、报错的原因指出了我们要加入spring-cloud-starter-loadbalancer。在项目的pom.xml文件加入依赖:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>

注意如果不清楚版本的对应关系,不用写版本号,使loadbalancer直接沿用springcloud的版本即可。不然会报错java.lang.ClassNotFoundException: org.springframework.cloud.client.loadbalancer.reactive.OnNoRibbonDefaultCondition

三、解决AbstractMethodError

做到这里,项目就可以启动了。但是还会有nacos和springcloud ribbon jar包不兼容的问题,会报错java.lang.AbstractMethodError: org.springframework.cloud.***flix.ribbon.RibbonLoadBalancerClient.choose(Ljava/lang/String;Lorg/springframework/cloud/client/loadbalancer/Request;)Lorg/springframework/cloud/client/ServiceInstance;

未完待续

转载请说明出处内容投诉
CSS教程_站长资源网 » No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买