最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

spring-cloud-gateway啟動踩坑及解決

 更新時間:2021年08月18日 08:44:21   作者:DDF_YiChen  
這篇文章主要介紹了spring-cloud-gateway啟動踩坑及解決方案,具有很好的參考價值,希望對大家有所幫助。

spring-cloud-gateway啟動踩坑

本人使用的版本是2.1.2,以下只記錄幾個小問題,但確實實實在在的把個人惡心的要死要活的找不到辦法,幾經(jīng)掙扎,最終解決。

更可恨的是開發(fā)的過程中,沒有出現(xiàn)異常,后來由于項目組其它人加了依賴,不知不覺對項目的兼容造成了英雄,真的是被撞的頭破血流,才找到原因

1、webflux與mvc不兼容

如類路徑中引用了webmvc會導(dǎo)致項目啟動不起來

異常1

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

異常2

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.convert.ConversionService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=webFluxConversionService)}

解決辦法,找到依賴webmvc的jar包,將webmvc排除即可,如

<dependency>
   <groupId>${project.groupId}</groupId>
   <artifactId>core</artifactId>
   <version>${project.version}</version>
   <exclusions>
        <!--
            1. webflux與webmvc不兼容,否則會項目啟動不起來
        -->
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </exclusion>
</dependency>

2、webflux使用netty作為容器

不能使用tomcat,表現(xiàn)形式為網(wǎng)關(guān)工作轉(zhuǎn)發(fā)正常,目標(biāo)服務(wù)返回數(shù)據(jù)也正常,但是網(wǎng)關(guān)會無法解析返回的數(shù)據(jù)并最終由網(wǎng)關(guān)將數(shù)據(jù)返回給客戶端

java.lang.ClassCastException: org.springframework.core.io.buffer.DefaultDataBufferFactory cannot be cast to org.springframework.core.io.buffer.NettyDataBufferFactory

解決辦法

https://github.com/spring-cloud/spring-cloud-gateway/issues/145

找到將tomcat依賴進(jìn)來的jar包,然后排除即可。需要注意的是,要看清楚自己項目依賴的tomcat具體的maven坐標(biāo)。

然后排除即可

<dependency>
  <groupId>${project.groupId}</groupId>
  <artifactId>core</artifactId>
  <version>${project.version}</version>
  <exclusions>
      <!--
          1. webflux與webmvc不兼容,否則會項目啟動不起來
          2. webflux使用Netty作為容器,如果使用tomcat,接口轉(zhuǎn)發(fā)正常,但是會導(dǎo)致服務(wù)間的數(shù)據(jù)無法解析
              java.lang.ClassCastException: org.springframework.core.io.buffer.DefaultDataBufferFactory
              cannot be cast to org.springframework.core.io.buffer.NettyDataBufferFactory -->
      <exclusion>
          <groupId>org.springframework</groupId>
          <artifactId>spring-webmvc</artifactId>
      </exclusion>
      <exclusion>
          <groupId>org.springframework.bootk</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
      </exclusion>
      <exclusion>
          <groupId>org.apache.tomcat.embed</groupId>
          <artifactId>tomcat-embed-core</artifactId>
      </exclusion>
      <exclusion>
          <groupId>org.apache.tomcat.embed</groupId>
          <artifactId>tomcat-embed-el</artifactId>
      </exclusion>
      <exclusion>
          <groupId>org.apache.tomcat.embed</groupId>
          <artifactId>tomcat-embed-websocket</artifactId>
      </exclusion>
  </exclusions>
</dependency>

3、后來實驗了下

關(guān)于1webflux和mvc不兼容項目啟動不起來的異常,如果項目中存在了tomcat的用來,則拋出的異常是

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

而如果沒有依賴tomcat則拋出的異常是

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.convert.ConversionService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=webFluxConversionService)}

很坑得spring cloud gateway 異常

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.convert.ConversionService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=webFluxConversionService)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1655) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1214) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1168) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
... 101 common frames omitted

這個異常是因為spring cloud gateway 是webflux 項目,引了含有web-starter得項目就會出現(xiàn)沖突。因為Hystrix-dashboard中含有web-starter,所以出現(xiàn)沖突。

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java Spring Boot實現(xiàn)簡易掃碼登錄詳解

    Java Spring Boot實現(xiàn)簡易掃碼登錄詳解

    這篇文章主要為大家詳細(xì)介紹了java Spring Boot實現(xiàn)app掃碼登錄功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2021-09-09
  • 解析maven的用法和幾個常用的命令(推薦)

    解析maven的用法和幾個常用的命令(推薦)

    maven最大的作用就是用于對項目中jar包依賴的統(tǒng)一管理。這篇文章主要介紹了maven的用法和幾個常用的命令,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-07-07
  • JAVA發(fā)送http get/post請求,調(diào)用http接口、方法詳解

    JAVA發(fā)送http get/post請求,調(diào)用http接口、方法詳解

    這篇文章主要介紹了Java發(fā)送http get/post請求調(diào)用接口/方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • 淺談Zookeeper開源客戶端框架Curator

    淺談Zookeeper開源客戶端框架Curator

    這篇文章主要介紹了淺談Zookeeper開源客戶端框架Curator的相關(guān)內(nèi)容,具有一定參考價值,需要的朋友可以了解下。
    2017-10-10
  • 詳解Spring獲取配置的三種方式

    詳解Spring獲取配置的三種方式

    這篇文章主要為大家詳細(xì)介紹了Spring獲取配置的三種方式:@Value方式動態(tài)獲取單個配置、@ConfigurationProperties+前綴方式批量獲取配置以及Environment動態(tài)獲取單個配置,感興趣的可以了解一下
    2022-03-03
  • Spring中事務(wù)用法示例及實現(xiàn)原理詳解

    Spring中事務(wù)用法示例及實現(xiàn)原理詳解

    這篇文章主要給大家介紹了關(guān)于Spring中事務(wù)用法示例及實現(xiàn)原理的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-11-11
  • mybatis升級mybatis-plus時踩到的一些坑

    mybatis升級mybatis-plus時踩到的一些坑

    這篇文章主要給大家介紹了關(guān)于mybatis升級mybatis-plus時踩到的一些坑,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • 使用JAVA+Maven+TestNG框架實現(xiàn)超詳細(xì)Appium測試安卓真機(jī)教程

    使用JAVA+Maven+TestNG框架實現(xiàn)超詳細(xì)Appium測試安卓真機(jī)教程

    這篇文章主要介紹了使用JAVA+Maven+TestNG框架實現(xiàn)超詳細(xì)Appium測試安卓真機(jī)教程,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-01-01
  • Java 使用 Graphql 搭建查詢服務(wù)詳解

    Java 使用 Graphql 搭建查詢服務(wù)詳解

    這篇文章主要介紹了Java 使用 Graphql 搭建查詢服務(wù)詳解的相關(guān)資料,需要的朋友可以參考下
    2016-12-12
  • Java攔截過濾器模式 (Intercepting Filter )實現(xiàn)方法

    Java攔截過濾器模式 (Intercepting Filter )實現(xiàn)方法

    攔截過濾器模式(Intercepting Filter Pattern)用于對應(yīng)用程序的請求或響應(yīng)做一些預(yù)處理/后處理,本文通過實例代碼介紹Java攔截過濾器模式 (Intercepting Filter )的相關(guān)知識,感興趣的朋友跟隨小編一起看看吧
    2024-03-03

最新評論

丹东市| 三亚市| 阿合奇县| 宜黄县| 鄄城县| 密云县| 晋宁县| 靖安县| 喜德县| 内黄县| 收藏| 辉县市| 怀来县| 钟山县| 和田县| 云霄县| 阿拉尔市| 通城县| 临猗县| 鄱阳县| 江达县| 库尔勒市| 禹州市| 乌什县| 共和县| 保定市| 开鲁县| 土默特右旗| 仙居县| 龙川县| 江口县| 榆中县| 吉隆县| 通海县| 江津市| 揭阳市| 六安市| 赤峰市| 开鲁县| 隆德县| 酒泉市|