springboot集成springCloud中gateway时启动报错的解决


Posted in Java/Android onJuly 16, 2021

在项目中引入springcloud中的gateway时报以下错误

Description:

Parameter 0 of method modifyRequestBodyGatewayFilterFactory in org.springframework.cloud.gateway.config.GatewayAutoConfiguration
required a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' that could not be found.

Action:
Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' in your configuration.

这个是由于依赖冲突,spring-cloud-starter-gateway与spring-boot-starter-web和spring-boot-starter-webflux依赖冲突

解决方式:

在引入gateway时过滤掉上面两个依赖

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-webflux</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

springboot整合gateway启动失败

问题:

springboot整合gateway启动失败

***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration.gatewayHttpClient(GatewayAutoConfiguration.java:622)
The following method did not exist:
reactor.netty.resources.ConnectionProvider.elastic(Ljava/lang/String;Ljava/time/Duration;Ljava/time/Duration;)Lreactor/netty/resources/ConnectionProvider;
The method's class, reactor.netty.resources.ConnectionProvider, is available from the following locations:
jar:file:/C:/Users/Administrator/.m2/repository/io/projectreactor/netty/reactor-netty/0.9.1.RELEASE/reactor-netty-0.9.1.RELEASE.jar!/reactor/netty/resources/ConnectionProvider.class
It was loaded from the following location:
file:/C:/Users/Administrator/.m2/repository/io/projectreactor/netty/reactor-netty/0.9.1.RELEASE/reactor-netty-0.9.1.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of reactor.netty.resources.ConnectionProvider
Disconnected from the target VM, address: '127.0.0.1:55875', transport: 'socket'
Process finished with exit code 1

这块主要是版本兼容的问题,

最初用的版本是:

<dependency>
            <groupId>io.projectreactor.netty</groupId>
            <artifactId>reactor-netty</artifactId>
            <version>0.9.4.RELEASE</version>
        </dependency>

网上有的是需要把这个版本降低,我这是降低了也不行

最后升高了版本改成了:

<dependency>
            <groupId>io.projectreactor.netty</groupId>
            <artifactId>reactor-netty</artifactId>
            <version>0.9.14.RELEASE</version>
        </dependency>

本项目里springboot版本为:2.3.1,根据自己项目需要吧,看一下自己项目中各个版本之间的问题

以上为个人经验,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Java/Android 相关文章推荐
解析Java中的static关键字
Jun 14 Java/Android
Java各种比较对象的方式的对比总结
Jun 20 Java/Android
springBoot基于webSocket实现扫码登录
Jun 22 Java/Android
Netty结合Protobuf进行编解码的方法
Jun 26 Java/Android
详解Spring事件发布与监听机制
Jun 30 Java/Android
Spring mvc是如何实现与数据库的前后端的连接操作的?
Jun 30 Java/Android
mybatis 解决从列名到属性名的自动映射失败问题
Jun 30 Java/Android
聊聊Lombok中的@Builder注解使用教程
Nov 17 Java/Android
Java GUI编程菜单组件实例详解
Apr 07 Java/Android
Flutter Navigator 实现路由传递参数
Apr 22 Java/Android
Java实现超大Excel文件解析(XSSF,SXSSF,easyExcel)
Jul 15 Java/Android
Java获取字符串编码格式实现思路
Sep 23 Java/Android
JavaWeb 入门篇(3)ServletContext 详解 具体应用
JavaWeb 入门:Hello Servlet
JavaWeb 入门篇:创建Web项目,Idea配置tomcat
mybatis 获取无数据的字段不显示的问题
Jul 15 #Java/Android
Lombok的详细使用及优缺点总结
Jul 15 #Java/Android
Java Socket实现多人聊天系统
看完这篇文章获得一些java if优化技巧
You might like
php使用gettimeofday函数返回当前时间并存放在关联数组里
2015/03/19 PHP
PHP查找与搜索数组元素方法总结
2015/06/12 PHP
PHP字符串中抽取子串操作实例分析
2019/06/22 PHP
使用laravel的migrate创建数据表的方法
2019/09/30 PHP
javascript Prototype 对象扩展
2009/05/15 Javascript
js几个验证函数代码
2010/03/25 Javascript
Three.js源码阅读笔记(基础的核心Core对象)
2012/12/27 Javascript
jQuery Ajax异步处理Json数据详解
2013/11/05 Javascript
js 设置缓存及获取设置的缓存
2014/05/08 Javascript
director.js实现前端路由使用实例
2015/02/03 Javascript
jquery插件corner实现圆角边框的方法
2015/03/09 Javascript
Javascript函数式编程简单介绍
2015/10/11 Javascript
JS与jQuery遍历Table所有单元格内容的方法
2015/12/07 Javascript
angular2倒计时组件使用详解
2017/01/12 Javascript
Vue.js实现模拟微信朋友圈开发demo
2017/04/20 Javascript
详解如何让Express支持async/await
2017/10/09 Javascript
[07:26]2015国际邀请赛第二日TOP10集锦
2015/08/06 DOTA
python中使用百度音乐搜索的api下载指定歌曲的lrc歌词
2014/07/18 Python
Python实现二分法算法实例
2015/02/02 Python
python制作爬虫爬取京东商品评论教程
2016/12/16 Python
python Matplotlib画图之调整字体大小的示例
2017/11/20 Python
python判断自身是否正在运行的方法
2019/08/08 Python
Python高级编程之继承问题详解(super与mro)
2019/11/19 Python
python实现学生成绩测评系统
2020/06/22 Python
python时间序列数据转为timestamp格式的方法
2020/08/03 Python
Python实现自动签到脚本功能
2020/08/20 Python
python+openCV对视频进行截取的实现
2020/11/27 Python
美国求婚钻戒网站:Super Jeweler
2016/08/27 全球购物
美国成衣女装品牌:CHICO’S
2016/09/19 全球购物
Napapijri西班牙在线商店:夹克、外套、运动衫等
2020/11/05 全球购物
在什么时候需要使用"常引用"
2015/12/31 面试题
超市中秋节促销方案
2014/03/21 职场文书
毕业生求职信范文
2014/06/29 职场文书
2015幼儿园庆元旦活动方案
2014/12/09 职场文书
2016年感恩节活动总结大全
2016/04/01 职场文书
根德5570型九灯四波段立体声收音机是电子管收音机的楷模 ? 再论5570
2022/04/05 无线电