org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is ja

具体报错:

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.AbstractMethodError: Receiver class org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient does not define or inherit an implementation of the resolved method 'abstract org.springframework.cloud.client.ServiceInstance choose(java.lang.String, org.springframework.cloud.client.loadbalancer.Request)' of interface org.springframework.cloud.client.loadbalancer.ServiceInstanceChooser.

解决办法:
引入了loadbalancer负载均衡,需要将ribbon排除掉,才能使loadbalancer生效。

<dependency>
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
     <!--问题:具体见error文件-->
     <exclusions>
         <exclusion>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
         </exclusion>
     </exclusions>
</dependency>

        在使用 Spring Cloud 中的负载均衡器(LoadBalancer)时,有时需要将 Ribbon 排除(exclude)掉才能使负载均衡器生效。这是因为在较新的 Spring Cloud 版本中,默认情况下会集成 Ribbon 负载均衡器,而排除 Ribbon 可以让负载均衡器使用其他实现。

        在 Spring Cloud 中,负载均衡器是通过 `@LoadBalanced` 注解实现的,默认情况下,它会使用 Ribbon 作为负载均衡的实现。Ribbon 是一个基于客户端的负载均衡器,它通过在客户端上选择合适的服务实例来实现负载均衡。然而,如果您不想使用 Ribbon(比如我想用nacos)或者您希望使用其他的负载均衡器实现,您可以将 Ribbon 排除掉。

  • 16
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值