admin管理员组文章数量:1794759
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please
畅购商城使用gateway任务中,启动GatewayWebApplication报如下错误:
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please remove spring-boot-starter-web dependency.首先确保自己的application.yml配置文件没有错误。
问题原因:Gateway 不支持spring boot web包
解决方法:在gateway项目pom依赖中使用标签<exclusion去除spring-boot-starter-web依赖。 有博客说还要移除springmvc和springwebflux依赖,然后再添加指定版本的springwebflux依赖,我最终成功后试了后其实不需要。可能的原因还是父工程会引入spring-boot-starter-web依赖,此时可以点击File->Project Structure移除相关的spring-boot-starter-web依赖,然后再启动工程。 gateway工程的完整依赖信:
<dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </exclusion> <!--<exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </exclusion>--> <exclusion> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-core</artifactId> </exclusion> </exclusions> </dependency> <!--<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> <version>2.1.4.RELEASE</version> </dependency>--> <!--<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.1.2.RELEASE</version> </dependency>--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </exclusion> </exclusions> </dependency> </dependencies>题外:此外,本人由于不小心从父工程引入的依赖和子工程指定的依赖存在版本不一致,还会有版本冲突问题。对于这些问题,只能耐心多参考一些博客,分析依赖的版本信,移除对应的冲突依赖。
另外一篇博客问题也是类似的,要注意子工程会从父工程引入依赖。
本文标签: classpathMVCspringincompatibleTime
版权声明:本文标题:Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686619155a86997.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论