【解决】org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.choose(Ljava/lang/String……

Problem symptoms:

Development environment: The local SpringCloud project upgrades the SpringCloud version, calls the Feign interface, and configures load balancing through the ribbon.

java.lang.AbstractMethodError: org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.choose(Ljava/lang/String;Lorg/springframework/cloud/client/loadbalancer/Request;)Lorg/springframework/cloud/client/ServiceInstance;
	at org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient.execute(FeignBlockingLoadBalancerClient.java:88) ~[spring-cloud-openfeign-core-3.0.7.jar:3.0.7]
	at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:119) ~[feign-core-10.12.jar:na]
	at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89) ~[feign-core-10.12.jar:na]
	at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100) ~[feign-core-10.12.jar:na]
	at com.sun.proxy.$Proxy80.queryString(Unknown Source) ~[na:na]

Insert image description here

Troubleshooting:

The main reason is that the jar package conflicts. The ribbon that nacos depends on and the ribbon of springcloud have different implementations of the same method and are incompatible.
Eliminate the spring-cloud-starter-netflix-ribbon dependency of nacos:
It is essentially a jar package conflict. The ribbon that nacos depends on and the ribbon of springcloud have different implementations of the same method, resulting in incompatibility.

As above, I found from online searches that it should be caused by jar package conflicts, but I did not introduce nacos. I opened the dependency analysis and found that eureka also introduced different versions of related packages. I eliminated the conflicting dependencies and tried again:
Insert image description here

Bug fixes

Find the eureka dependency of the pom file and exclude ribbon-related packages:

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            <!--排除ribbon-->
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-netflex-ribbon</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

mvn recompiles, the project starts again, and the problem is solved

Guess you like

Origin blog.csdn.net/weixin_41674401/article/details/135171424