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内存模型之happens-before概念详解
Jun 13 Java/Android
Springboot集成阿里云OSS上传文件系统教程
Jun 28 Java/Android
Java 数组内置函数toArray详解
Jun 28 Java/Android
gateway与spring-boot-starter-web冲突问题的解决
Jul 16 Java/Android
Java网络编程之UDP实现原理解析
Sep 04 Java/Android
OpenCV实现普通阈值
Nov 17 Java/Android
Netty分布式客户端接入流程初始化源码分析
Mar 25 Java/Android
Java 常见的限流算法详细分析并实现
Apr 07 Java/Android
JAVA长虹键法之建造者Builder模式实现
Apr 10 Java/Android
IDEA 2022 Translation 未知错误 翻译文档失败
Apr 24 Java/Android
Android开发手册Chip监听及ChipGroup监听
Jun 10 Java/Android
java实现自定义时钟并实现走时功能
Jun 21 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
smarty实例教程
2006/11/19 PHP
smarty section简介与用法分析
2008/10/03 PHP
php采用curl实现伪造IP来源的方法
2014/11/21 PHP
PHP实现的sqlite数据库连接类
2014/12/12 PHP
PHP PDO fetch 模式各种参数的输出结果一览
2015/01/07 PHP
php计算整个mysql数据库大小的方法
2015/06/19 PHP
PHP生成word文档的三种实现方式
2016/11/14 PHP
PHP编程实现的TCP服务端和客户端功能示例
2018/04/13 PHP
ASP.NET jQuery 实例2 (表单中使用回车在TextBox之间向下移动)
2012/01/13 Javascript
jQuery循环滚动展示代码 可应用到文字和图片上
2012/05/11 Javascript
Jquery实现控件的隐藏和显示实例
2014/02/08 Javascript
JavaScript中的typeof操作符用法实例
2014/04/05 Javascript
jQuery统计指定子元素数量的方法
2015/03/17 Javascript
优化RequireJS项目的相关技巧总结
2015/07/01 Javascript
Jquery实现遮罩层的简单实例(就是弹出DIV周围都灰色不能操作)
2016/07/14 Javascript
js获取浏览器高度 窗口高度 元素尺寸 偏移属性的方法
2016/11/21 Javascript
vuejs开发组件分享之H5图片上传、压缩及拍照旋转的问题处理
2017/03/06 Javascript
浅谈js-FCC算法Friendly Date Ranges(详解)
2017/04/10 Javascript
js和jquery中获取非行间样式
2017/05/05 jQuery
Node.js学习之查询字符串解析querystring详解
2017/09/28 Javascript
基于jQuery Ajax实现下拉框无刷新联动
2017/12/06 jQuery
关于vue的语法规则检测报错问题的解决
2018/05/21 Javascript
vue数据操作之点击事件实现num加减功能示例
2019/01/19 Javascript
[42:32]完美世界DOTA2联赛PWL S2 LBZS vs FTD.C 第二场 11.27
2020/12/01 DOTA
Windows下PyMongo下载及安装教程
2015/04/27 Python
python进阶_浅谈面向对象进阶
2017/08/17 Python
python+unittest+requests实现接口自动化的方法
2018/11/29 Python
python如何制作缩略图
2019/04/30 Python
Python 切分数组实例解析
2019/11/07 Python
Html5+JS实现手机摇一摇功能
2015/04/24 HTML / CSS
英国最大的滑板品牌选择:Route One
2019/09/22 全球购物
历史专业学生的自我评价
2014/02/28 职场文书
应届生面试求职信
2014/07/02 职场文书
2015年植树节活动总结
2015/02/06 职场文书
幼师个人总结范文
2015/02/28 职场文书