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

關(guān)于Springboot+gateway整合依賴并處理依賴沖突問題

 更新時間:2022年01月06日 16:54:56   作者:怒吼的蘿卜  
這篇文章主要介紹了Springboot+gateway整合依賴并處理依賴沖突問題,給大家提到了spring boot版本和spring cloud版本,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

正文

spring boot版本和spring cloud版本

框架版本
SpringBoot2.3.12.RELEASE
SpringCloudHoxton.SR1

pom依賴

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.12.RELEASE</version>
        <relativePath/>
    </parent>

    <dependencies>
        <!-- spring-boot-starter -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <!-- gateway與spring-boot-starter-web沖突(spring-boot-starter-webflux) -->
        <!--<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>-->

        <!-- springCloud gateway -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
            <!--<exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-webflux</artifactId>
                </exclusion>
            </exclusions>-->
        </dependency>

        <!-- httpClient依賴,缺少此依賴api網(wǎng)關(guān)轉(zhuǎn)發(fā)請求時可能發(fā)生503錯誤 -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.5</version>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Hoxton.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

配置文件(application.yml)

server:
  port: 8700
spring:
  application:
    name: sca-gateway
  cloud:
    gateway:
      routes: #配置網(wǎng)關(guān)路由規(guī)則
        - id: route01  #路由id,自己指定一個唯一值即可
          uri: http://localhost:8081/ #網(wǎng)關(guān)幫我們轉(zhuǎn)發(fā)的url
          predicates: ###斷言(謂此):匹配請求規(guī)則
            - Path=/nacos/provider/echo/**  #請求路徑定義,此路徑對應(yīng)uri中的資源
          filters: ##網(wǎng)關(guān)過濾器,用于對謂詞中的內(nèi)容進(jìn)行判斷分析以及處理
            - StripPrefix=1 #轉(zhuǎn)發(fā)之前去掉path中第一層路徑,例如nacos

依賴沖突問題

**********************************************************
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please remove spring-boot-starter-web dependency.
**********************************************************
2020-07-21 10:12:27.253  WARN 8576 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gatewayControllerEndpoint' defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration$GatewayActuatorConfiguration.class]: Unsatisfied dependency expressed through method 'gatewayControllerEndpoint' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'modifyRequestBodyGatewayFilterFactory' defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]: Unsatisfied dependency expressed through method 'modifyRequestBodyGatewayFilterFactory' parameter 0; nested 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: {}
2020-07-21 10:12:27.253  INFO 8576 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-07-21 10:12:27.273  INFO 8576 --- [           main] ConditionEvaluationReportLoggingListener : 
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-21 10:12:27.388 ERROR 8576 --- [           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.
2020-07-21 10:12:27.398  WARN 8576 --- [           main] o.s.boot.SpringApplication               : Unable to close ApplicationContext
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springApplicationAdminRegistrar' defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: Unsatisfied dependency expressed through method 'springApplicationAdminRegistrar' parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.env.Environment' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:245) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:197) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:134) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.boot.availability.AvailabilityChangeEvent.publish(AvailabilityChangeEvent.java:81) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.availability.AvailabilityChangeEvent.publish(AvailabilityChangeEvent.java:67) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:167) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:978) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:814) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at online.hupeng.cloud.gateway.GateWayApplication.main(GateWayApplication.java:12) [classes/:na]
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.env.Environment' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1716) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1272) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1226) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
    ... 23 common frames omitted

注:spring-cloud-starter-gatewayspring-boot-starter-web依賴發(fā)生沖突,因?yàn)間ateway依賴包內(nèi)置spring-boot-starter-webflux依賴,與web包內(nèi)的spring-boot-starter-webflux依賴起了沖突。

解決方法

spring-boot-starter-webspring-依賴包剔除,或剔除boot-starter-webflux依賴包。

1. 剔除web包
<!-- gateway與spring-boot-starter-web沖突(spring-boot-starter-webflux) -->
<!--<dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>
</dependency>-->
1. 剔除webflux包
<!-- gateway與spring-boot-starter-web沖突(spring-boot-starter-webflux) -->
<dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>     <exclusions>          <exclusion>               <groupId>org.springframework.boot</groupId>               <artifactId>spring-boot-starter-webflux</artifactId>          </exclusion>     </exclusions></dependency>

到此這篇關(guān)于Springboot+gateway整合依賴并處理依賴沖突問題的文章就介紹到這了,更多相關(guān)Springboot gateway依賴沖突內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java設(shè)計(jì)模式之單例模式簡單解析

    Java設(shè)計(jì)模式之單例模式簡單解析

    這篇文章主要介紹了Java設(shè)計(jì)模式之單例模式簡單解析,單例模式的優(yōu)點(diǎn)在于在內(nèi)存中某個類只有一個實(shí)例,減少了內(nèi)存的開銷,尤其是頻繁的創(chuàng)建和銷毀實(shí)例,避免對資源的多重暫用,需要的朋友可以參考下
    2023-12-12
  • JavaSE一維數(shù)組和二維數(shù)組用法詳解

    JavaSE一維數(shù)組和二維數(shù)組用法詳解

    數(shù)組存儲同一種數(shù)據(jù)類型多個元素的集合,既可以存儲基本數(shù)據(jù)類型,也可以存儲引用數(shù)據(jù)類型,這篇文章主要給大家介紹了關(guān)于JavaSE一維數(shù)組和二維數(shù)組用法的相關(guān)資料,需要的朋友可以參考下
    2024-04-04
  • 詳解如何快速定位和解決JSON錯誤(以Protobuf的JsonFormat.ParseException為例)

    詳解如何快速定位和解決JSON錯誤(以Protobuf的JsonFormat.ParseException為例)

    在開發(fā)過程中,JSON數(shù)據(jù)的解析是一個常見的操作,尤其是在微服務(wù)架構(gòu)中,服務(wù)之間的通信通常依賴于JSON格式的數(shù)據(jù),然而,JSON數(shù)據(jù)的格式錯誤往往會導(dǎo)致解析失敗,進(jìn)而引發(fā)系統(tǒng)異常,本文將以一個實(shí)際的錯誤案例為例,詳細(xì)講解如何快速定位和解決JSON解析錯誤
    2025-03-03
  • MyBatis寫入Json字段以及Json字段轉(zhuǎn)對象示例詳解

    MyBatis寫入Json字段以及Json字段轉(zhuǎn)對象示例詳解

    這篇文章主要給大家介紹了關(guān)于MyBatis寫入Json字段以及Json字段轉(zhuǎn)對象的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-07-07
  • SpringBoot整合jasypt實(shí)現(xiàn)數(shù)據(jù)加密的步驟

    SpringBoot整合jasypt實(shí)現(xiàn)數(shù)據(jù)加密的步驟

    聽說過jasypt嗎?它可是一個超級流行的Java庫哦,提供了簡單又高效的加密和解密接口,整合jasypt后,我們的SpringBoot應(yīng)用就能輕松處理敏感數(shù)據(jù)的加密和解密,而不必為復(fù)雜的加密算法頭疼啦,下面給大家介紹SpringBoot整合jasypt實(shí)現(xiàn)數(shù)據(jù)加密的步驟,感興趣的朋友一起看看吧
    2025-04-04
  • SpringBoot處理接口冪等性的兩種方法詳解

    SpringBoot處理接口冪等性的兩種方法詳解

    接口冪等性處理算是一個非常常見的需求了,我們在很多項(xiàng)目中其實(shí)都會遇到。本文為大家總結(jié)了兩個處理接口冪等性的兩種常見方案,需要的可以參考一下
    2022-06-06
  • Java StackTraceElement實(shí)例代碼

    Java StackTraceElement實(shí)例代碼

    這篇文章主要介紹了Java StackTraceElement實(shí)例代碼,分享了相關(guān)代碼示例,小編覺得還是挺不錯的,具有一定借鑒價值,需要的朋友可以參考下
    2018-02-02
  • Java獲取當(dāng)前時間的時間戳(13位和10位)

    Java獲取當(dāng)前時間的時間戳(13位和10位)

    本文主要介紹了Java獲取當(dāng)前時間的時間戳(13位和10位),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-07-07
  • 使用jaxp進(jìn)行dom解析_動力節(jié)點(diǎn)Java學(xué)院整理

    使用jaxp進(jìn)行dom解析_動力節(jié)點(diǎn)Java學(xué)院整理

    這篇文章主要介紹了使用jaxp進(jìn)行dom解析的相關(guān)資料,需要的朋友可以參考下
    2017-08-08
  • java向多線程中傳遞參數(shù)的三種方法詳細(xì)介紹

    java向多線程中傳遞參數(shù)的三種方法詳細(xì)介紹

    但在多線程的異步開發(fā)模式下,數(shù)據(jù)的傳遞和返回和同步開發(fā)模式有很大的區(qū)別。由于線程的運(yùn)行和結(jié)束是不可預(yù)料的,因此,在傳遞和返回?cái)?shù)據(jù)時就無法象函數(shù)一樣通過函數(shù)參數(shù)和return語句來返回?cái)?shù)據(jù)
    2012-11-11

最新評論

和顺县| 阜新市| 门源| 托克逊县| 海兴县| 兰坪| 巴楚县| 景德镇市| 临沧市| 平江县| 富民县| 灵寿县| 繁峙县| 邓州市| 吉首市| 汤原县| 绥阳县| 黄浦区| 富宁县| 绵竹市| 南汇区| 迁西县| 闵行区| 平阴县| 河池市| 临澧县| 宁阳县| 镶黄旗| 龙游县| 咸阳市| 会东县| 白城市| 渑池县| 理塘县| 兴文县| 甘孜县| 禹州市| 宜昌市| 美姑县| 神木县| 西盟|