目录
前言
本篇博客使用Spring Cloud 2021版本、Nacos 1.4.0、Spring Boot 2.7.6、Gateway
系列文章目录
Spring Boot2.0系列教程合集、Spring Cloud系列教程合集、Spring Boot常见错误合集、Spring Cloud常见错误合集_zjh_746140129的博客-CSDN博客
以下是本篇文章正文内容,下面案例可供参考
一、项目启动报错
1、报错截图
2、错误信息
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.
二、解决方案
1.错误原因
在Spring Boot整合GateWay时, GateWay组件中的 【spring-boot-starter-webflux】 和springboot作为web项目启动必不可少的 【spring-boot-starter-web】 出现冲突,网上查阅资料有建议在pom中移除一个spring-boot-starter-web,尝试了还是不行,后面通过在配置文件添加如下配置解决:
spring:
main:
web-application-type: reactive