0

我正在尝试使用 Spring WebFlux Webclient。试图在石英 cron 作业中创建一个简单的网络客户端

this.webClient = WebClient.create(this.queryUrl);

我确保 queryUrl 有效。

但是,我遇到以下错误:

java.lang.ExceptionInInitializerError: null
at org.springframework.web.reactive.function.client.ExchangeStrategies.withDefaults(ExchangeStrategies.java:67)
at org.springframework.web.reactive.function.client.DefaultWebClientBuilder.initExchangeStrategies(DefaultWebClientBuilder.java:302)
at org.springframework.web.reactive.function.client.DefaultWebClientBuilder.build(DefaultWebClientBuilder.java:269)
at org.springframework.web.reactive.function.client.WebClient.create(WebClient.java:154)

跟踪代码,我发现 DefaultExchangeStrategiesBuilder 为空。

有谁知道缺少什么?这是一个简单的网络客户端。

谢谢。

4

1 回答 1

0
<dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.13.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.13.0</version>
    </dependency>

添加这些依赖项并确保版本相同。我以前只有杰克逊核心。

我试图将这项工作从石英中移出并直接在 main.js 中运行。它仍然抛出异常,但它不同,然后我查了一下,有人问了这个问题和解决方案,以确保需要包含两个杰克逊包并且版本必须相同。

然后我将它们添加到 pom 文件中。尝试运行这项工作,它奏效了。将工作放回石英运行,它也有效。

于 2021-10-08T04:24:53.070 回答