目录
- 一、问题现象
- 二、解决办法
- 1、本次异常配置
- 2、修改后的配置
- 三、原因分析
一、问题现象
2023-12-05 16:21:53.680]|[ INFO]|[80173]|[main]|[]|[]|[trationDelegate$BeanPostProcessorChecker:335]|[Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactiveLoadBalancerConfig' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactiveLoadBalancerConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-12-05 16:21:53.681]|[ INFO]|[80173]|[main]|[]|[]|[trationDelegate$BeanPostProcessorChecker:335]|[Bean 'deferringLoadBalancerExchangeFilterFunction' of type [org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-12-05 16:21:53.835]|[ WARN]|[80173]|[main]|[]|[]|[onfigReactiveWebServerApplicationContext:559]|[Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is java.lang.NoSuchFieldError: sharedInstance
2023-12-05 16:21:53.852]|[ INFO]|[80173]|[main]|[]|[]|[ConditionEvaluationReportLoggingListener:136]|[
……………………
2023-12-05 16:21:53.869]|[ERROR]|[80173]|[main]|[]|[]|[o.s.boot.SpringApplication :837]|[Application run failed
org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is java.lang.NoSuchFieldError: sharedInstance
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:80) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) ~[spring-context-5.2.10.RELEASE.jar:5.2.10.RELEASE]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:62) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
at com.upkeep.gateway.GatewayApplication.main(GatewayApplication.java:12) ~[classes/:na]
Caused by: java.lang.NoSuchFieldError: sharedInstance
…… ……
二、解决办法
1、本次异常配置
本次异常对应的版本为:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>
2、修改后的配置
将Cloud版本修改为3.1.3,可以消除本异常,但此版本又太高了,又会带来别的问题,同样无法正常启动。最后修改如下:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
<version>2.2.9.RELEASE</version>
</dependency>
三、原因分析
还是老生常谈的Spring Boot和Spring Cloud版本适配关系问题所致,详细适配信息请参考官网:https://spring.io/projects/spring-cloud,部分如下: