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

作者 : admin 本文共991个字,预计阅读时间需要3分钟 发布时间: 2024-06-17 共1人阅读

具体报错:

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生效。


     org.springframework.cloud
     spring-cloud-starter-alibaba-nacos-discovery
     
     
         
             org.springframework.cloud
             spring-cloud-starter-netflix-ribbon
         
     

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

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

本站无任何商业行为
个人在线分享-虚灵IT资料分享 » org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is ja
E-->