【问题标题】:WebClient create java.lang.ExceptionInInitializerError: null ExchangeStrategies.withDefaultsWebClient 创建 java.lang.ExceptionInInitializerError: null ExchangeStrategies.withDefaults
【发布时间】:2021-10-07 15:25:33
【问题描述】:

我正在尝试使用 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 为空。

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

谢谢。

【问题讨论】:

  • 它是否与 webclient 相关,在 org.quartz 的石英作业调度程序中初始化......CollectorJob.execute(CollectorJob.java:35)。 core.JobRunShell.run(JobRunShell.java:202)

标签: spring webclient webflux


【解决方案1】:
<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>

添加这些依赖项并确保版本相同。 我以前只有jackson-core。

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-22
    • 1970-01-01
    • 1970-01-01
    • 2016-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多