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文件加入依赖:


    org.springframework.cloud
    spring-cloud-loadbalancer

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

三、解决AbstractMethodError

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

未完待续

你可能感兴趣的:(┉┇异常和报错,java,spring,boot,spring)