Spring Cloud GateWay异常处理:DefaultDataBuffer cannot be cast to org.springframework.core.io.b

Spring Cloud GateWay异常处理:DefaultDataBuffer cannot be cast to org.springframework.core.io.b

1. 问题描述:
使用spring cloud gateway组件时,按照官方文档配置后发现后台报错,并且配置不起作用

配置信息:
Spring Cloud GateWay异常处理:DefaultDataBuffer cannot be cast to org.springframework.core.io.b
错误信息:Spring Cloud GateWay异常处理:DefaultDataBuffer cannot be cast to org.springframework.core.io.b
2. 解决办法:
网上资料说与SpringBoot中的spring-web-starter依赖冲突,但是在网关服务pom文件里没有添加spring-web-starter依赖。最后发现在公共模块的pom里添加了tomcat相关的依赖,导致报错错误;把依赖干掉即可
Spring Cloud GateWay异常处理:DefaultDataBuffer cannot be cast to org.springframework.core.io.b
3. 总结
由于springcloud的gateway使用的是webflux,默认使用netty,所以从依赖中排除 tomcat相关的依赖即可 (包括SpringBoot中的spring-web-starter依赖)