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 相关文章推荐
为什么在foreach循环中JAVA集合不能添加或删除元素
Jun 11 Java/Android
Java实现斗地主之洗牌发牌
Jun 14 Java/Android
Java各种比较对象的方式的对比总结
Jun 20 Java/Android
Maven学习----Maven安装与环境变量配置教程
Jun 29 Java/Android
Spring mvc是如何实现与数据库的前后端的连接操作的?
Jun 30 Java/Android
mybatis 获取无数据的字段不显示的问题
Jul 15 Java/Android
Java如何实现通过键盘输入一个数组
Feb 15 Java/Android
Elasticsearch 配置详解
Apr 19 Java/Android
JavaScript正则表达式实现注册信息校验功能
May 30 Java/Android
Java中生成微信小程序太阳码的实现方案
Jun 01 Java/Android
SpringBoot项目多数据源及mybatis 驼峰失效的问题解决方法
Jul 07 Java/Android
java实现web实时消息推送的七种方案
Jul 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
投票管理程序
2006/10/09 PHP
PHP读取XML值的代码(推荐)
2011/01/01 PHP
深入PHP empty(),isset(),is_null()的实例测试详解
2013/06/06 PHP
解析php通过cookies获取远程网页的指定代码
2013/06/25 PHP
shell脚本作为保证PHP脚本不挂掉的守护进程实例分享
2013/07/15 PHP
PHP输入输出流学习笔记
2015/05/12 PHP
浅谈php中include文件变量作用域
2015/06/18 PHP
CI配置多数据库访问的方法
2016/03/28 PHP
PHP实现一个限制实例化次数的类示例
2019/09/16 PHP
jQuery get和post 方法传值注意事项
2009/11/03 Javascript
用JS实现3D球状标签云示例代码
2013/12/01 Javascript
设置jsf的选择框h:selectOneMenu为不可编辑状态的方法
2014/01/07 Javascript
js实现网页右上角滑出会自动消失大幅广告的方法
2015/02/27 Javascript
Javascript自执行匿名函数(function() { })()的原理浅析
2016/05/15 Javascript
JS HTML5实现拖拽移动列表效果
2020/08/27 Javascript
基于游标的分页接口实现代码示例
2018/11/12 Javascript
vue自定义树状结构图的实现方法
2020/10/18 Javascript
Vue 打包的静态文件不能直接运行的原因及解决办法
2020/11/19 Vue.js
使用Python的内建模块collections的教程
2015/04/28 Python
Python查找函数f(x)=0根的解决方法
2015/05/07 Python
浅谈python中np.array的shape( ,)与( ,1)的区别
2018/06/04 Python
python读取和保存图片5种方法对比
2018/09/12 Python
python的debug实用工具 pdb详解
2019/07/12 Python
Python进阶之使用selenium爬取淘宝商品信息功能示例
2019/09/16 Python
python 利用pywifi模块实现连接网络破解wifi密码实时监控网络
2019/09/16 Python
Django values()和value_list()的使用
2020/03/31 Python
HTML5 transform三维立方体实现360无死角三维旋转效果
2014/08/22 HTML / CSS
嘻哈珠宝品牌:KRKC&CO
2020/10/19 全球购物
财务会计实习报告体会
2013/12/20 职场文书
求职毕业生自荐书
2014/02/08 职场文书
广场舞大赛策划方案
2014/05/31 职场文书
学年个人总结范文
2015/03/05 职场文书
初中生思想道德自我评价
2015/03/09 职场文书
MySQL系列之一 MariaDB-server安装
2021/07/02 MySQL
JavaScript 原型与原型链详情
2021/11/02 Javascript
OpenCV实现反阈值二值化
2021/11/17 Java/Android