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

报错信息

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:

spring:
  main:
    web-application-type: reactive

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-04-23 01:16:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-23 01:16:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-23 01:16:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-23 01:16:04       18 阅读

热门阅读

  1. nginx根据二级目录转发服务以及带/和不带/的区别

    2024-04-23 01:16:04       18 阅读
  2. Rust 模式匹配中的& 和 ref

    2024-04-23 01:16:04       13 阅读
  3. RedisHttpSession反序列化UID问题跟踪

    2024-04-23 01:16:04       13 阅读
  4. 【Git】git revert 命令(撤销 commit 改动)

    2024-04-23 01:16:04       22 阅读
  5. 深度学习概念

    2024-04-23 01:16:04       12 阅读
  6. AJAX请求(axios篇)

    2024-04-23 01:16:04       14 阅读
  7. UDF小白入门

    2024-04-23 01:16:04       14 阅读
  8. git工具的安装及使用

    2024-04-23 01:16:04       12 阅读
  9. backtracking Leetcode 回溯算法题

    2024-04-23 01:16:04       11 阅读