當啟動SpringCloudGateway網關服務的時候,沒注意好依賴問題,出現了這個問題:?
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.?
解決辦法就是:刪除SpringMVC的依賴,即下列依賴。
?
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId> </dependency>
分享一個管理SpringCloud依賴問題的方法,引入與你SpringBoot版本相對于的spring-cloud-dependencies版本,然后通過下面這種方法管理依賴,就可以避免依賴問題了。
<dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>2021.0.3</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement>
?在使用的時候就只需要如下引入依賴了:
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency>