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

编程知识 更新时间:2023-05-02 05:29:27

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

 

更多推荐

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

本文发布于:2023-04-26 06:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/d7c1952ba0f1b075bbd5b9ce4ca11648.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:报错   bean   type   Gateway   defining

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 104514文章数
  • 26215阅读数
  • 0评论数