环境

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>

启动项目

.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: 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=3b99c69a-fc8e-3d3b-abbd-2c424a860051
2021-04-21 11:12:37.206  INFO 18208 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration' 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 'loadBalancerWebClientBuilderBeanPostProcessor' defined in class path resource [org/springframework/cloud/client/loadbalancer/reactive/LoadBalancerBeanPostProcessorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'loadBalancerWebClientBuilderBeanPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction<?>' 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 'debug' 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 'org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction' in your configuration.


Process finished with exit code 1

漂亮,启动直接报错

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

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

解决方案

1.引入负载均衡依赖

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

2.降低springboot与springcloud版本,降到2.4以下(不包含2.4),例如,我将版本做了如下修改:

<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降低到了:2.3.8.RELEASE,springcloud降低到了:Hoxton.SR10,重新编译启动之后,报错没有了,版本降级的时候一定要注意springboot与springcloud的对应关系。

两种方式二选一即可。

这个错误应该是springcloud升级导致的,springcloud还真是坑啊

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐