在使用gateway,啟動服務時報錯
阿新 • • 發佈:2020-12-20
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
以上是springboot和SpringCloud的所使用的版本,
在使用gateway,啟動服務時出現如下報錯。
*************************** APPLICATION FAILED TO START *************************** Description: An attempt was made to call a method that does not exist. The attempt was made from the following location: org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration.reactorNettyWebSocketClient(GatewayAutoConfiguration.java:803) The following method did not exist: org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient.setHandlePing(Z)V The method's class, org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient, is available from the following locations: jar:file:/E:/codes/maven_reps/org/springframework/spring-webflux/5.2.3.RELEASE/spring-webflux-5.2.3.RELEASE.jar!/org/springframework/web/reactive/socket/client/ReactorNettyWebSocketClient.classIt was loaded from the following location: file:/E:/codes/maven_reps/org/springframework/spring-webflux/5.2.3.RELEASE/spring-webflux-5.2.3.RELEASE.jar Action: Correct the classpath of your application so that it contains a single, compatible version of org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient Process finished with exit code 1
搜尋資料看到有人說是由於依賴衝突,spring-cloud-starter-gateway與spring-boot-starter-web和spring-boot-starter-webflux依賴衝突
我這裡在引入gateway時去掉webflux就能正常啟動了
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </exclusion> </exclusions> </dependency>