Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.

报错信息

powershell 复制代码
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.

解析

这个错误信息是因为你的项目中同时存在Spring MVC和Spring Cloud Gateway,这两者是不兼容的。

Spring Cloud Gateway是基于Spring WebFlux构建的,Spring WebFlux是一个非阻塞的反应式web框架,而Spring MVC是一个阻塞的框架,它包含在spring-boot-starter-web依赖中。 要解决这个问题,你需要做以下其中一项:

①:如果不需要,从你的pom.xml中移除spring-boot-starter-web依赖。

②:如果你在同一个应用中需要Spring MVC和Spring Cloud Gateway,你可以在你的application.yml或application.properties文件中将web应用类型设置为REACTIVE。

以下是如何在application.yml中将web应用类型设置为REACTIVE:

yaml 复制代码
spring:
  main:
    web-application-type: reactive
相关推荐
哎呀呀嗯呀呀9 分钟前
class 031 位运算的骚操作
java·算法·位运算
2401_8581205313 分钟前
古典舞在线交流平台:SpringBoot设计与实现详解
java·spring boot·后端
大白飞飞20 分钟前
IDEA创建、导入、删除maven项目
java·maven·intellij-idea
赐你岁月如歌25 分钟前
如何使用ssm实现基于web的网站的设计与实现+vue
java·后端·ssm
2401_857297911 小时前
秋招内推2025-招联金融
java·前端·算法·金融·求职招聘
一 乐1 小时前
考研论坛平台|考研论坛小程序系统|基于java和微信小程序的考研论坛平台小程序设计与实现(源码+数据库+文档)
java·数据库·学习·考研·微信·小程序·源码
一 乐1 小时前
租拼车平台|小区租拼车管理|基于java的小区租拼车管理信息系统小程序设计与实现(源码+数据库+文档)
java·数据库·vue.js·微信·notepad++·拼车
xmh-sxh-13142 小时前
如何选择数据库架构
java
jxxchallenger2 小时前
踩坑spring cloud gateway /actuator/gateway/refresh不生效
java·数据库·gateway
远望樱花兔2 小时前
【d59】【Java】【力扣】146.LRU缓存
java·开发语言·算法