In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how Springboot+gateway integrates dependencies and deals with dependency conflicts". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how Springboot+gateway integrates dependencies and handles dependency conflicts.
Text
Spring boot version and spring cloud version
The framework version of SpringBoot2.3.12.RELEASESpringCloudHoxton.SR1pom depends on org.springframework.boot spring-boot-starter-parent 2.3.12.RELEASE org.springframework.boot spring-boot-starter org.springframework.cloud spring-cloud-starter -gateway org.apache.httpcomponents httpclient 4.5.5 org.springframework.cloud spring-cloud-dependencies Hoxton.SR1 pom import Configuration file (application.yml) server: port: 8700spring: application: name: sca-gateway cloud: gateway: routes: # configure gateway routing rules-id: route01 # routing id You can specify a unique value uri: url predicates: # asserted for us to forward by the http://localhost:8081/ # gateway (that is): match the request rule-Path=/nacos/provider/echo/** # request path definition, which corresponds to the resource filters: # # gateway filter in uri Used to judge, analyze and process the content in the predicate-StripPrefix=1 # remove the first layer path in path before forwarding For example, nacos dependency conflicts
* * *
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 ConfigServletWebServerApplicationContext 12 ConfigServletWebServerApplicationContext 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 o.apache.catalina.core.StandardService 12 INFO 27.253 8576-[main] o.apache.catalina.core.StandardService: Stopping service [Tomcat]
2020-07-21 10 ConditionEvaluationReportLoggingListener 12 ConditionEvaluationReportLoggingListener 27.273 INFO 8576-[main]:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-21 10 o.s.b.d.LoggingFailureAnalysisReporter 12 o.s.b.d.LoggingFailureAnalysisReporter 27.388 ERROR 8576-[main]:
* *
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 o.s.boot.SpringApplication 12 WARN 27.398 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
Note: spring-cloud-starter-gateway and spring-boot-starter-web dependencies conflict because gateway relies on the built-in spring-boot-starter-webflux dependency in the package, which conflicts with the spring-boot-starter-webflux dependency in the web package.
Solution method
Remove the spring-boot-starter-webspring- dependency package, or the boot-starter-webflux dependency package.
1. Get rid of web package 1. With the elimination of the webflux package org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-webflux, I believe you have a deeper understanding of "how Springboot+gateway integrates dependencies and handles dependency conflicts". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.