关于SpringCloud(Nacos注册中心)集成Gateway时,路由跳转出错的解决方法

描述:

使用Gateway网关做路由跳转时,发送请求后后台报错:

2020-02-24 17:33:12.221  WARN 5312 --- [ctor-http-nio-4] i.n.c.AbstractChannelHandlerContext      :
An exception 'java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: reactor/netty/NettyPipeline$SendOptions' [enable DEBUG level for full stacktrace] was thrown by a user handler's exceptionCaught() method while handling the following exception:

java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: reactor/netty/NettyPipeline$SendOptions
	at org.springframework.cloud.gateway.filter.NettyRoutingFilter.lambda$filter$3(NettyRoutingFilter.java:134) ~[spring-cloud-gateway-core-2.1.5.RELEASE.jar:2.1.5.RELEASE]
	at reactor.netty.http.client.HttpClientConnect$HttpClientHandler.requestWithBody(HttpClientConnect.java:580) ~[reactor-netty-0.9.4.RELEASE.jar:0.9.4.RELEASE]
......

原因及解决办法:

出错时因为版本问题,目前我使用的Gateway是2.1.5.RELEASE,而我用的SpringBoot版本是2.2.4.RELEASE,两者并不兼容。

如果降低Gateway版本,会在启动时报错:

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'hiddenHttpMethodFilter', defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

显然不行。所以选择降低SpringBoot的版本,2.1.x.RELEASE都可以,我选择的是2.1.6.RELEASE

你可能感兴趣的:(框架)