Spring Cloud Gateway 中GET请求能正常访问,POST请求出现Unable to handle DataBuffer

报错信息如下:

bash 复制代码
java.lang.IllegalArgumentException: Unable to handle DataBuffer of type class org.springframework.http.server.reactive.UndertowServerHttpRequest$UndertowDataBuffer
        at org.springframework.cloud.gateway.filter.NettyRoutingFilter.getByteBuf(NettyRoutingFilter.java:219)
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
        |_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
        |_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
        |_ checkpoint ⇢ HTTP POST "/XX/XXX" [ExceptionHandlingWebHandler]
Stack trace:
                at org.springframework.cloud.gateway.filter.NettyRoutingFilter.getByteBuf(NettyRoutingFilter.java:219)
                at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:100)

因为是部署在测试环境不是本地调试的,本地调试是正常的,所以具体的没断点进去看。

然后GET请求是能正常请求到的,而POST请求就全部都不行。

网上查找到的资料也是挺零散的,可能比较少人遇到吧。

按照大佬的解决方法,也依旧解决不了:(这个可以尝试一下)https://blog.csdn.net/qq_38225558/article/details/113045145

后面无意中看见了另外一个大佬的解决思路,解决了。感谢。
https://juejin.cn/post/6979510711781163016

将Undertow容器修改为Tomcat容器

xml 复制代码
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>

gateway的版本:2.2.5.RELEASE

项目里没有看见有引入Undertow的依赖,我直接加上tomcat的依赖,然后就正常了。

相关推荐
TT哇8 分钟前
【多线程-进阶】常⻅的锁策略
java
EnCi Zheng21 分钟前
JPA 连接 PostgreSQL 数据库完全指南
java·数据库·spring boot·后端·postgresql
tuokuac1 小时前
MVC的含义
java·mvc
为java加瓦1 小时前
IO多路复用的两种触发机制:ET和LT触发机制。以及IO操作是异步的还是同步的理解
java·服务器·网络
_extraordinary_1 小时前
Java SpringBoot(一)--- 下载Spring相关插件,创建一个Spring项目,创建项目出现的问题
java·spring boot·spring
聪明的笨猪猪2 小时前
Java Spring “核心基础”面试清单(含超通俗生活案例与深度理解)
java·经验分享·笔记·面试
_Power_Y2 小时前
SSM面试题学习
java·开发语言·学习
不要再敲了2 小时前
Spring Security 完整使用指南
java·后端·spring
还是鼠鼠3 小时前
《黑马商城》微服务保护-详细介绍【简单易懂注释版】
java·spring boot·spring·spring cloud·sentinel·maven
她说..3 小时前
通过git拉取前端项目
java·前端·git·vscode·拉取代码