热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

springcloud整合gateway引入nacos报Parameter0ofmethodloadBalancerWebClientBuilderBeanPostProcessorino

环境springboot:2.4.5springcloud:2020.0.2依赖org.springfra

环境

springboot:2.4.5
springcloud:2020.0.2


依赖

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency>

启动项目

. ____ _ __ _ _/\\ / ___&#39;_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | &#39;
_ | &#39;_| | &#39;_ \/ _&#96; | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) )&#39; |____| .__|_| |_|_| |_\__, | / / / /&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;|_|&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;|___/&#61;/_/_/_/:: Spring Boot :: (v2.4.5)2021-04-21 11:12:36.190 INFO 18208 --- [ main] com.hxjm.fish.FishGwServiceApplication : Starting FishGwServiceApplication using Java 1.8.0_211 on LAPTOP-LLATKJ27 with PID 18208 (D:\hxjm\big-fish\fish-gw-service\target\classes started by 36142 in D:\hxjm)
2021-04-21 11:12:36.193 INFO 18208 --- [ main] com.hxjm.fish.FishGwServiceApplication : No active profile set, falling back to default profiles: default
2021-04-21 11:12:37.141 INFO 18208 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id&#61;3b99c69a-fc8e-3d3b-abbd-2c424a860051
2021-04-21 11:12:37.206 INFO 18208 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean &#39;org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration&#39; of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-04-21 11:12:37.224 WARN 18208 --- [ main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name &#39;loadBalancerWebClientBuilderBeanPostProcessor&#39; defined in class path resource [org/springframework/cloud/client/loadbalancer/reactive/LoadBalancerBeanPostProcessorAutoConfiguration.class]: Unsatisfied dependency expressed through method &#39;loadBalancerWebClientBuilderBeanPostProcessor&#39; parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type &#39;org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction&#39; available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2021-04-21 11:12:37.241 INFO 18208 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with &#39;debug&#39; enabled.
2021-04-21 11:12:37.261 ERROR 18208 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************
APPLICATION FAILED TO START
***************************Description:Parameter 0 of method loadBalancerWebClientBuilderBeanPostProcessor in org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration required a bean of type &#39;org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction&#39; that could not be found.Action:Consider defining a bean of type &#39;org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction&#39; in your configuration.Process finished with exit code 1

漂亮&#xff0c;启动直接报错

Parameter 0 of method loadBalancerWebClientBuilderBeanPostProcessor in org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration required a bean of type &#39;org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction&#39; that could not be found

在这里面我们可以看到&#xff0c;这很明显是缺少负载均衡的依赖。


解决方案

1.引入负载均衡依赖

<!--负载均衡--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId></dependency>

2.降低springboot与springcloud版本&#xff0c;降到2.4以下&#xff08;不包含2.4&#xff09;&#xff0c;例如&#xff0c;我将版本做了如下修改&#xff1a;

<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.8.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><properties><spring-cloud.version>Hoxton.SR10</spring-cloud.version></properties><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement>

我这里将springboot降低到了&#xff1a;2.3.8.RELEASE&#xff0c;springcloud降低到了&#xff1a;Hoxton.SR10&#xff0c;重新编译启动之后&#xff0c;报错没有了&#xff0c;版本降级的时候一定要注意springboot与springcloud的对应关系。

两种方式二选一即可。

这个错误应该是springcloud升级导致的&#xff0c;springcloud还真是坑啊


推荐阅读
author-avatar
mobiledu2502856247
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有