Caused by: java.lang.ClassNotFoundException: cn.itcast.feign.clients.UserClient at java.base/jdk.in

 

 

Principle analysis:

After the Spring Cloud 2020 version, the dependence on Netflix is ​​removed by default, including Ribbon . The official default recommendation is to use Spring Cloud Loadbalancer to officially replace Ribbon, and it has become the only implementation of Spring Cloud load balancer.

Solution:

Notice:

If it is a version before Hoxton, the default load balancer is Ribbon, you need to remove the Ribbon reference and add the configuration spring.cloud.loadbalancer.ribbon.enabled: false

Exclude ribbon dependencies

<dependency>
   <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    <exclusions>
        <exclusion>
            <groupId>com.netflix.ribbon</groupId>
            <artifactId>ribbon</artifactId>
        </exclusion>
    </exclusions>
</dependency>

add dependencies

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

 

run successfully 

Reference article:

No Feign Client for loadBalancing defined. error

Could not find class [org.springframework.cloud.client.loadbalancer.LoadBalancerProperties]

 

Guess you like

Origin blog.csdn.net/m0_59281987/article/details/132048570