admin管理员组

文章数量:1530518

在给其他微服务添加网关Gateway时,在给Gateway项目添加Gateway依赖时,项目无法启动

问题为:

考虑在配置中增加org.springframework.http.codec.ServerCodecConfigurer。

一般我们在web项目中都会添加spring-boot-starter-web和spring-boot-starter-actuator的依赖用于项目的监控。

但问题就在这里,我把这两个依赖注释掉之后再次启动项目即可恢复正常。

正常启动

 

 

问题总结:

在网上翻阅关于Gateway与Web依赖冲突的问题,总结问题原因

Gateway与Zuul不一样,Gateway用的是长连接,使用非阻塞的netty-webflux,Zuul的底层是使用Springmvc,基于servlet2.5,所以在Gateway的项目中是不能添加spring-boot-starter-web的依赖,而actuator的依赖一般与web一同出现,所以就一并注释掉。

相关问题:

也有同学遇到报错为:

springmvc found on classpath which is incompatible with spring cloud gateway at this time Please remove spring-boot-starter-web dependency

这个报错就很明白了,Gateway和web依赖不兼容,请移除依赖。

希望以上的总结可以帮助到正在学习Gateway的同学。

 

本文标签: 报错beantypeGatewaydefining