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的依赖,然后就正常了。

相关推荐
q***33371 小时前
oracle 12c查看执行过的sql及当前正在执行的sql
java·sql·oracle
Y***h1874 小时前
第二章 Spring中的Bean
java·后端·spring
8***29315 小时前
解决 Tomcat 跨域问题 - Tomcat 配置静态文件和 Java Web 服务(Spring MVC Springboot)同时允许跨域
java·前端·spring
CoderYanger5 小时前
优选算法-栈:67.基本计算器Ⅱ
java·开发语言·算法·leetcode·职场和发展·1024程序员节
q***06295 小时前
Tomcat的升级
java·tomcat
多多*5 小时前
Java复习 操作系统原理 计算机网络相关 2025年11月23日
java·开发语言·网络·算法·spring·microsoft·maven
青云交5 小时前
Java 大视界 -- Java 大数据在智能物流无人配送车路径规划与协同调度中的应用
java·spark·路径规划·大数据分析·智能物流·无人配送车·协同调度
摇滚侠5 小时前
2025最新 SpringCloud 教程,从单体到集群架构,笔记02
笔记·spring cloud·架构
d***81725 小时前
解决SpringBoot项目启动错误:找不到或无法加载主类
java·spring boot·后端
ᐇ9596 小时前
Java集合框架深度实战:构建智能教育管理与娱乐系统
java·开发语言·娱乐