微服务整合gateway启动报Error creating bean with name ‘org.springframework.cloud.gateway.config错误
在进行spring cloudalibaba项目集成时,创建gateway模块时,报以下错误
attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration$SpringMvcFoundOnClasspathConfiguration': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration$SpringMvcFoundOnClasspathConfiguration]: Constructor threw exception; nested exception is org.springframework.cloud.gateway.support.MvcFoundOnClasspathException
2022-12-17 21:46:22.154 INFO 6112 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-12-17 21:46:22.173 INFO 6112 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-12-17 21:46:22.200 ERROR 6112 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.
Action:
Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.
Disconnected from the target VM, address: '127.0.0.1:2897', transport: 'socket'
Process finished with exit code 1
原因是引用gateway依赖和springboot依赖重复导致,如下。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
如下图所示,我们能在项目中的Dependencies不难发现,在引用gateway依赖时已经引入了spring-boot依赖
解决办法是删掉gateway项目中的springboot依赖解决
对应的pom文件内如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.wish</groupId>
<artifactId>network-manager-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.wish</groupId>
<artifactId>gateway-application</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>gateway-application</name>
<description>Demo project for Spring Boot</description>
<dependencies>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
</dependencies>
</project>
效果如下
至此问题解决
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhfjbcjc
-
phphotoshoptudy_pro+phpStorm运行php代码(解决404 Not Found 和 502 Bad Gateway 问题)
-
微服务整合gateway启动报Error creating bean with name ‘org.springframework.cloud.gateway.config错误
-
spring cloud alibaba gateway (网关)
-
网关Gateway
-
Python获取网卡信息Gateway、NIC Name、NIC MAC Address、IP Address、IP Netmask
-
完美解决Spring Cloud Gateway跨域配置不生效问题
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
怎样阻止微信小程序自动打开
PHP中文网 06-13 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
photoshop蒙版画笔没反应怎么办
PHP中文网 06-24