admin管理员组

文章数量:1794759

关于gateWay配置问题 Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this

关于gateWay配置问题 Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this

 今天配置Gateway网关的时候发现 报了这样一个问题Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please remove spring-boot-starter-web dependency.

我去检查pom文件的时候发现spring-boot-starter-web 已经去掉了。但是启动还是报错,只能手动排除了,所以添加了下面的依赖。

<exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> </exclusion> </exclusions>

解决~ 但是访问网关地址的时候,又报了这样一个问题

org.springframework.core.io.buffer.DefaultDataBufferFactory cannot be cast to org.springframework.core.io.buffer.NettyDataBufferFactory

java.lang.ClassCastException: org.springframework.core.io.buffer.DefaultDataBufferFactory cannot be cast to org.springframework.core.io.buffer.NettyDataBufferFactory

 

大概的意思就是 springcloud的gateway使用的是webflux,默认使用netty,所以要从依赖中排除 tomcat相关的依赖 ,就可以了。

所以完整的依赖应该是

<exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> </exclusion> <exclusion> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-core</artifactId> </exclusion> </exclusions>

 

本文标签: MVCspringGatewayclasspath