栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

添加Gateway依赖后启动报错Consider defining a bean of type ‘org.springframework.http.codec.ServerCodecConfigur

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

添加Gateway依赖后启动报错Consider defining a bean of type ‘org.springframework.http.codec.ServerCodecConfigur

在给其他微服务添加网关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的同学。

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/287448.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号