报错截图:
java.lang.ClassCastException: org.springframework.core.io.buffer.DefaultDataBufferFactory cannot be cast to org.springframework.core.io.buffer.NettyDataBufferFactory
at org.springframework.cloud.gateway.filter.NettyWriteResponseFilter.lambda$filter$1(NettyWriteResponseFilter.java:82) ~[spring-cloud-gateway-core-2.2.0.RELEASE.jar:2.2.0.RELEASE]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ HTTP GET "/eduservice/teacher/findAll" [ExceptionHandlingWebHandler]
原因是:引入的依赖中有spring-web等依赖,排除或者删除掉这些依赖,gateway就能正常运行了!GateWay仅仅需要spring-cloud-starter-gateway
可以看到通过网关访问成功!