我在服务网格中使用spring-cloud-gateay,启动时出现错误:
Caused by: java.lang.NoSuchMethodError: org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient.<init>(Ljava/util/function/Consumer;)V
依赖项:
[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ gateway ---
[INFO] cn.rctech.egg:gateway:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.0.3.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.0.3.RELEASE:compile
[INFO] | | \- org.springframework:spring-context:jar:5.1.6.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:5.1.6.RELEASE:compile
[INFO] | | +- org.springframework:spring-beans:jar:5.1.6.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:5.1.6.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.3.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.3.RELEASE:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] | | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | +- org.springframework:spring-core:jar:5.1.6.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.1.6.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] +- org.springframework.cloud:spring-cloud-starter-gateway:jar:2.0.3.RELEASE:compile
[INFO] | +- org.springframework.cloud:spring-cloud-gateway-core:jar:2.0.3.RELEASE:compile
[INFO] | | \- io.projectreactor.addons:reactor-extra:jar:3.1.6.RELEASE:compile
[INFO] | | \- io.projectreactor:reactor-core:jar:3.1.8.RELEASE:compile
[INFO] | | \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
[INFO] | \- org.springframework.boot:spring-boot-starter-webflux:jar:2.0.3.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.0.3.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.7:compile
[INFO] | | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.7:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.7:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.7:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.7:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.0.3.RELEASE:compile
[INFO] | | \- io.projectreactor.ipc:reactor-netty:jar:0.7.8.RELEASE:compile
[INFO] | | +- io.netty:netty-codec-http:jar:4.1.25.Final:compile
[INFO] | | | \- io.netty:netty-codec:jar:4.1.25.Final:compile
[INFO] | | +- io.netty:netty-handler:jar:4.1.25.Final:compile
[INFO] | | | +- io.netty:netty-buffer:jar:4.1.25.Final:compile
[INFO] | | | \- io.netty:netty-transport:jar:4.1.25.Final:compile
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.25.Final:compile
[INFO] | | +- io.netty:netty-handler-proxy:jar:4.1.25.Final:compile
[INFO] | | | \- io.netty:netty-codec-socks:jar:4.1.25.Final:compile
[INFO] | | \- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.25.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.25.Final:compile
[INFO] | | \- io.netty:netty-transport-native-unix-common:jar:4.1.25.Final:compile
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.0.10.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] | +- org.springframework:spring-web:jar:5.1.6.RELEASE:compile
[INFO] | +- org.springframework:spring-webflux:jar:5.1.6.RELEASE:compile
[INFO] | \- org.synchronoss.cloud:nio-multipart-parser:jar:1.1.0:compile
[INFO] | \- org.synchronoss.cloud:nio-stream-storage:jar:1.1.3:compile
[INFO] +- com.alibaba.boot:nacos-config-spring-boot-starter:jar:0.2.1:compile
[INFO] | +- com.alibaba.nacos:nacos-spring-context:jar:0.2.3-RC1:compile
[INFO] | | +- com.alibaba.nacos:nacos-client:jar:1.0.0:compile
[INFO] | | | +- com.alibaba.nacos:nacos-common:jar:1.0.0:compile
[INFO] | | | | +- commons-io:commons-io:jar:2.6:compile
[INFO] | | | | \- org.apache.commons:commons-lang3:jar:3.7:compile
[INFO] | | | +- com.alibaba.nacos:nacos-api:jar:1.0.0:compile
[INFO] | | | | \- com.alibaba:fastjson:jar:1.2.47:compile
[INFO] | | | +- com.google.guava:guava:jar:23.0:compile
[INFO] | | | | +- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | | | | +- com.google.errorprone:error_prone_annotations:jar:2.0.18:compile
[INFO] | | | | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] | | | | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO] | | | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | | | +- com.fasterxml.jackson.core:jackson-core:jar:2.9.7:compile
[INFO] | | | \- io.prometheus:simpleclient:jar:0.5.0:compile
[INFO] | | \- com.alibaba.spring:spring-context-support:jar:1.0.1:compile
[INFO] | +- com.alibaba.boot:nacos-config-spring-boot-autoconfigure:jar:0.2.1:compile
[INFO] | \- com.alibaba.boot:nacos-spring-boot-base:jar:0.2.1:compile
[INFO] +- com.alibaba.boot:nacos-discovery-spring-boot-starter:jar:0.2.1:compile
[INFO] | \- com.alibaba.boot:nacos-discovery-spring-boot-autoconfigure:jar:0.2.1:compile
[INFO] \- org.springframework.cloud:spring-cloud-starter:jar:2.0.3.RELEASE:compile
[INFO] +- org.springframework.cloud:spring-cloud-context:jar:2.0.3.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-crypto:jar:5.0.6.RELEASE:compile
[INFO] +- org.springframework.cloud:spring-cloud-commons:jar:2.0.3.RELEASE:compile
[INFO] \- org.springframework.security:spring-security-rsa:jar:1.0.7.RELEASE:compile
[INFO] \- org.bouncycastle:bcpkix-jdk15on:jar:1.60:compile
[INFO] \- org.bouncycastle:bcprov-jdk15on:jar:1.60:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
在阅读源代码之后,我发现org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient
的{{1}}是:
org.springframework:spring-webflux:5.1.6.RELEASE
这是上面的第二个构造函数,需要一个public class ReactorNettyWebSocketClient implements WebSocketClient {
private static final Log logger = LogFactory.getLog(ReactorNettyWebSocketClient.class);
private final HttpClient httpClient;
/**
* Default constructor.
*/
public ReactorNettyWebSocketClient() {
this(HttpClient.create());
}
/**
* Constructor that accepts an existing {@link HttpClient} builder.
* @since 5.1
*/
public ReactorNettyWebSocketClient(HttpClient httpClient) {
Assert.notNull(httpClient, "HttpClient is required");
this.httpClient = httpClient;
}
.....
}
对象与HttpClient
不匹配。
org/springframework/cloud/gateway/config/GatewayAutoConfiguration$NettyConfiguration.class
答案 0 :(得分:1)
此bug记录在Github上。
这是将起作用的Versions
的正确组合之一:
父母:
<parent>
<groupSId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.X</version> // I tested on <version>2.2.1.RELEASE</version>
</parent>
云版本:
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>