简体   繁体   English

添加 jsonschema2pojo-core 后嵌入式 Kafka 测试用例出错

[英]Embedded Kafka test cases are error after adding jsonschema2pojo-core

I have an application that created with Spring boot and Spring kafka libraries.我有一个使用 Spring 引导和 Spring kafka 库创建的应用程序。 Now I added jsonschema2pojo-core library to my pom file.现在我将 jsonschema2pojo-core 库添加到我的 pom 文件中。 After adding this jar file my test cases are failing with below error添加此 jar 文件后,我的测试用例失败并出现以下错误

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedKafka': Invocation of init method failed;原因:org.springframework.beans.factory.BeanCreationException:创建名为“embeddedKafka”的bean时出错:调用init方法失败; nested exception is java.lang.NoClassDefFoundError: scala/runtime/java8/JFunction0$mcZ$sp Caused by: java.lang.NoClassDefFoundError: scala/runtime/java8/JFunction0$mcZ$sp嵌套异常是 java.lang.NoClassDefFoundError: scala/runtime/java8/JFunction0$mcZ$sp 引起:java.lang.NoClassDefFoundError: scala/runtime/sp8/JFc

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.1.RELEASE</version>
    <relativePath />
</parent>

    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
    </dependency>
    <!-- Test Dependencies -->
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka-test</artifactId>
        <scope>test</scope>
    </dependency>

      <dependency>
        <groupId>org.jsonschema2pojo</groupId>
        <artifactId>jsonschema2pojo-core</artifactId>
        <version>1.0.2</version>
      </dependency>

It's probably similar to this https://docs.spring.io/spring-kafka/docs/2.5.11.RELEASE/reference/html/#jacksonscala-incompatibility它可能类似于此https://docs.spring.io/spring-kafka/docs/2.5.11.RELEASE/reference/html/#jacksonscala-incompatibility

with the library pulling in an incompatible scala library.该库引入了不兼容的 scala 库。

Yes, adding是的,添加

<dependency>
    <groupId>org.scala-lang</groupId>
    <artifactId>scala-library</artifactId>
    <version>2.12.11</version>
</dependency>

fixed it for me;为我修好了; but I can't guarantee that jsonschema2pojo will work with that version.但我不能保证jsonschema2pojo可以使用该版本。

The scala folks are notorious for breaking API changes in patch releases. scala 人因在补丁版本中破坏 API 更改而臭名昭著。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM