[英]java.lang.NoSuchMethodError: 'reactor.util.context.ContextView reactor.core.publisher.MonoSink.contextView()'
After upgrade Spring Boot version from 2.6.6 to 2.6.7, I'm getting below error while executing web client rest calls.将 Spring Boot 版本从 2.6.6 升级到 2.6.7 后,执行 Web 客户端休息调用时出现以下错误。 Any idea?
任何想法?
Sample code示例代码
public void execute(BiConsumer<ResponseEntity<JsonNode>, Throwable> responseConsumer) {
WebClient.RequestBodyUriSpec uriSpec = getUriSpec();
Mono<ResponseEntity<JsonNode>> responseEntityMono = uriSpec
.uri(this::buildUri)//"localhost:1234")//
.headers(this::setHeaders)
.body(insertBody())
.retrieve().onRawStatus(i -> i == 599,
response -> response.bodyToMono(String.class)
.map(body -> new ExternalException(599, body)))
.toEntity(JsonNode.class);
CompletableFuture<ResponseEntity<JsonNode>> completableFuture = responseEntityMono.toFuture();
completableFuture.whenCompleteAsync(responseConsumer);
}
Upgrade you pom.xml升级你的 pom.xml
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.4.3</version>
</dependency>
The method that can't be found is in the class MonoSink (in reactor-core project): https://github.com/reactor/reactor-core/blob/main/reactor-core/src/main/java/reactor/core/publisher/MonoSink.java找不到的方法在 MonoSink 类中(在 reactor-core 项目中): https ://github.com/reactor/reactor-core/blob/main/reactor-core/src/main/java/reactor /core/publisher/MonoSink.java
Since this was an exception you got after upgrading from spring boot version 2.6.6, I guess that the class that can't find it is HttpClientConnect (in project reactor-netty-http).由于这是从 Spring Boot 版本 2.6.6 升级后遇到的异常,我猜找不到它的类是 HttpClientConnect(在项目 reactor-netty-http 中)。 It would be good to have the whole stack exception though.
不过,最好有整个堆栈异常。
@jiangjianbo is not wrong saying that you need to update reactor-core to solve this but not to version 3.4.3. @jiangjianbo 说你需要更新 reactor-core 来解决这个问题并没有错,但不是 3.4.3 版本。 It should be at least the version 3.4.17 (That said I would take latest one, which at the time of writing this is 3.4.19).
它至少应该是 3.4.17 版本(也就是说我会采用最新的版本,在撰写本文时它是 3.4.19)。 As you can see in version 3.4.16 contextView() was not yet created: https://github.com/reactor/reactor-core/blob/v3.4.16/reactor-core/src/main/java/reactor/core/publisher/MonoSink.java
正如您在 3.4.16 版本中看到的,尚未创建 contextView(): https ://github.com/reactor/reactor-core/blob/v3.4.16/reactor-core/src/main/java/reactor/core /publisher/MonoSink.java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.