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中重写父类方法加不加@Override详解
Jun 21 Java/Android
解决ObjectMapper.convertValue() 遇到的一些问题
Jun 30 Java/Android
SpringBoot读取Resource下文件的4种方法
Jul 02 Java/Android
JavaGUI模仿QQ聊天功能完整版
Jul 04 Java/Android
Java实现聊天机器人完善版
Jul 04 Java/Android
java泛型通配符详解
Jul 25 Java/Android
idea以任意顺序debug多线程程序的具体用法
Aug 30 Java/Android
使用logback实现按自己的需求打印日志到自定义的文件里
Aug 30 Java/Android
Java 在线考试云平台的实现
Nov 23 Java/Android
解决persistence.xml配置文件修改存放路径的问题
Feb 24 Java/Android
Spring Boot接口定义和全局异常统一处理
Apr 20 Java/Android
Java 定时任务技术趋势简介
May 04 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+javascript液晶时钟
2006/10/09 PHP
解析PHP提交后跳转
2013/06/23 PHP
PHP 只允许指定IP访问(允许*号通配符过滤IP)
2014/07/08 PHP
php实现mysql数据库连接操作及用户管理
2015/11/08 PHP
分享别人写的一个小型js框架
2007/08/13 Javascript
Extjs学习笔记之九 数据模型(上)
2010/01/11 Javascript
对jQuery的事件绑定的一些思考(补充)
2013/04/20 Javascript
Node.js编码规范
2014/07/14 Javascript
png在IE6 下无法透明的解决方法汇总
2015/05/21 Javascript
纯JavaScript实现的分页插件实例
2015/07/14 Javascript
Angular中$compile源码分析
2016/01/28 Javascript
indexedDB bootstrap angularjs之 MVC DOMO (应用示例)
2016/06/20 Javascript
easyui form validate总是返回false的原因及解决方法
2016/11/07 Javascript
AngularJS实现用户登录状态判断的方法(Model添加拦截过滤器,路由增加限制)
2016/12/12 Javascript
JavaScript实现同一个页面打开多张图片
2016/12/29 Javascript
javascript 使用正则test( )第一次是 true,第二次是false
2017/02/22 Javascript
jQuery实现鼠标响应式透明度渐变动画效果示例
2018/02/13 jQuery
详解react-redux插件入门
2018/04/19 Javascript
JS实现的汉字与Unicode码相互转化功能分析
2018/05/25 Javascript
Vue弹出菜单功能的实现代码
2018/09/12 Javascript
python实现class对象转换成json/字典的方法
2016/03/11 Python
Python实现的当前时间多加一天、一小时、一分钟操作示例
2018/05/21 Python
django 框架实现的用户注册、登录、退出功能示例
2019/11/28 Python
Python属性和内建属性实例解析
2020/01/14 Python
Python3如何使用多线程升程序运行速度
2020/08/11 Python
欧洲最大的婴幼儿服装及内衣公司:Petit Bateau(小帆船)
2016/08/16 全球购物
意大利婴儿产品网上商店:Mukako
2018/10/14 全球购物
美国在线购买内衣网站:HerRoom
2020/02/22 全球购物
总经理职责
2013/12/22 职场文书
舞蹈专业大学生职业规划范文
2014/03/12 职场文书
群众路线教育实践活动自我剖析思想汇报
2014/10/04 职场文书
诚信教育主题班会
2015/08/13 职场文书
医院岗前培训心得体会
2016/01/08 职场文书
MySQL表字段时间设置默认值
2021/05/13 MySQL
python代码实现备忘录案例讲解
2021/07/26 Python
Java中try catch处理异常示例
2021/12/06 Java/Android