如何解决Spring Cloud Gateway和OAuth2不兼容的问题

技术如何解决Spring Cloud Gateway和OAuth2不兼容的问题今天就跟大家聊聊有关如何解决Spring Cloud Gateway和OAuth2不兼容的问题,可能很多人都不太了解,为了让大家更加了解,小编

今天就跟大家聊聊有关如何解决春云网关和OAuth2不兼容的问题,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

问题版本

春云版本芬奇利:号。释放;排放;发布

Oauth3版本: 2.0.0.RELEASE

春天版本: 5.0.7.RELEASE

错误描述

在春云网关与OAuth3的整合过程中遇到启动错误

如下:

2019-10-0901:16:27 .235错误18320-[ost-startStOp-1]o . s . b . web。嵌入式。雄猫。tomcatstarter : error startingmcatcontext。异常3360组织。弹簧框架。豆子。工厂。bean创建例外。消息: error screenatingbanwith name ' servletendpointregistrator '定义类路径资源[org/spring framework/bootenstedexception org。弹簧框架。比恩。beans实例化except :未能实例化[org。弹簧框架。靴子。安森。端点。网络。servletendpointregistrator]:工厂方法“servletendpointregistrator”三个异常;nestedexceptionorg。弹簧框架。豆子。工厂。不可持续的unsustaifieddependencycexception :创建名为“gateway controllerendpoint”的bea时出错定义类路径资源[org/spring framework/cloud/gateway auto configuration $ gateway activator configuration。class]:不可持续的dependency cexpressthrough method“gateway controllerendpoint”参数2;nestedexceptionorg。弹簧框架。豆子。工厂。不可持续unsustaifieddependencycexception 3360创建名为“modifierequestbodygatewayfilterfactory”的bea时出错定义类路径资源[org/spring framework/cloud/gateway auto configuration。类]:不可持续的dependencycxpressthrough method“modifierrequestbodygatewayfilterfactory”参数0;嵌套的

nbsp;exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.http.codec.ServerCodecConfigurer' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2019-10-09 01:16:27.280  INFO 18320 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-10-09 01:16:27.287  WARN 18320 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [reactor-http-nio-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
 sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
 sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
 sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
 io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:756)
 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:411)
 io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
 java.lang.Thread.run(Thread.java:748)
2019-10-09 01:16:27.287  WARN 18320 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [reactor-http-nio-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
 sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
 sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
 sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
 io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:756)
 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:411)
 io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
 java.lang.Thread.run(Thread.java:748)
2019-10-09 01:16:27.288  WARN 18320 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [reactor-http-nio-3] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
 sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
 sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
 sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
 io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:756)
 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:411)
 io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
 java.lang.Thread.run(Thread.java:748)
2019-10-09 01:16:27.288  WARN 18320 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [reactor-http-nio-4] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
 sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
 sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
 sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
 io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:756)
 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:411)
 io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
 java.lang.Thread.run(Thread.java:748)
2019-10-09 01:16:27.291  WARN 18320 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [reactor-http-nio-5] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
 sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
 sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
 sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
 io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:756)
 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:411)
 io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
 java.lang.Thread.run(Thread.java:748)
2019-10-09 01:16:27.292  WARN 18320 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [reactor-http-nio-6] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
 sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
 sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
 sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
 io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:756)
 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:411)
 io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
 java.lang.Thread.run(Thread.java:748)
2019-10-09 01:16:27.293  WARN 18320 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [reactor-http-nio-7] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
 sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
 sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
 sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
 io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:756)
 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:411)
 io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
 java.lang.Thread.run(Thread.java:748)
2019-10-09 01:16:27.294  WARN 18320 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [reactor-http-nio-8] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
 sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
 sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
 sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
 sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
 io.netty.channel.nio.SelectedSelectionKeySetSelector.select(SelectedSelectionKeySetSelector.java:62)
 io.netty.channel.nio.NioEventLoop.select(NioEventLoop.java:756)
 io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:411)
 io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
 java.lang.Thread.run(Thread.java:748)
2019-10-09 01:16:27.300  WARN 18320 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2019-10-09 01:16:27.320  INFO 18320 --- [           main] ConditionEvaluationReportLoggingListener : 
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-10-09 01:16:27.635 ERROR 18320 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
***************************
APPLICATION FAILED TO START
***************************
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.

你遇到的情况有可能和我稍有不同

官方解答

问题描述ISSUES : https://github.com/spring-cloud/spring-cloud-gateway/issues/478

官方解答ISSUES : https://github.com/spring-cloud/spring-cloud-security/issues/141

简单来说是 Spring Security 和 Spring Cloud Gateway 不兼容的问题.

解决方法有二:

1. 放弃整合,在Gateway中实现自己的鉴权方式
2. 将 Spring Security 升级为 5.1.X

此处有新版本解决方案实例 : https://github.com/artemMartynenko/spring-cloud-gateway-oauth3-sso-sample-application

题外话

开源框架的版本真是永远也追不上,不要盲目追求新版本

最优的技术是能稳定支撑自己业务的技术,而不是最新的技术.

看完上述内容,你们对如何解决Spring Cloud Gateway和OAuth2不兼容的问题有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。

内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/42834.html

(0)

相关推荐

  • 怎么分析MySQL性能优化的参数

    技术怎么分析MySQL性能优化的参数怎么分析MySQL性能优化的参数,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。MySQL的优化我分为两个

    攻略 2021年11月23日
  • 如何解析LoRaWAN设备数据及开源MQTT SDK设备端模拟

    技术如何解析LoRaWAN设备数据及开源MQTT SDK设备端模拟这期内容当中小编将会给大家带来有关如何解析LoRaWAN设备数据及开源MQTT SDK设备端模拟,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文

    攻略 2021年10月22日
  • qq靓号注册,怎样免费注册五位数的qq号

    技术qq靓号注册,怎样免费注册五位数的qq号现在五位数的QQ号已经无法免费申请,只能申请到10位数的QQ号。想要10位数以下的QQ号,只能通过购买QQ靓号获得。申请QQ靓号方法:1qq靓号注册、选择QQ号码;先登录到QQ

    生活 2021年10月22日
  • 如何分析Vue2cube-ui时间选择器

    技术怎么解析Vue2 cube-ui时间选择器这篇文章给大家介绍怎么解析Vue2 cube-ui时间选择器,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。前言vue2 整合 cube-ui 时间选择器

    攻略 2021年12月20日
  • 兄弟造句两种意思造句,形容“好兄弟”的词语有哪些

    技术兄弟造句两种意思造句,形容“好兄弟”的词语有哪些八拜之交(bābàizhījiāo):八拜:原指古代世交子弟谒见长辈的礼节;交:友谊。旧时朋友结为兄弟的关系。造句:今日在圣贤炉前成了八拜之交兄弟造句两种意思造句,有福

    生活 2021年10月24日
  • Spring5路径匹配器PathPattern有什么用

    技术Spring5路径匹配器PathPattern有什么用这篇文章主要为大家展示了“Spring5路径匹配器PathPattern有什么用”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并

    攻略 2021年11月24日