【问题标题】:java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce at kafka.utils.TestUtils.tempDir(TestUtils.scala)java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce 在 kafka.utils.TestUtils.tempDir(TestUtils.scala)
【发布时间】:2020-12-28 00:04:20
【问题描述】:

使用@EmbeddedKafka(topics = { "checkins" })时 我收到一个错误

Caused by: java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce
    at kafka.utils.TestUtils.tempDir(TestUtils.scala)
    at org.springframework.kafka.test.EmbeddedKafkaBroker$EmbeddedZookeeper.<init>(EmbeddedKafkaBroker.java:738)
    at org.springframework.kafka.test.EmbeddedKafkaBroker.afterPropertiesSet(EmbeddedKafkaBroker.java:291)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790)

我正在使用 spring boot 2.3.3.RELEASE

我的 gradle 看起来像

            compile("io.confluent:kafka-json-serializer:$confluentJsonVersion")
            compile ("org.apache.kafka:kafka-clients: $kafkaVersion")
            implementation ("org.springframework.boot:spring-boot-starter-validation")
            implementation("org.springframework.kafka:spring-kafak:$springKafkaVersion")
            implementation "org.apache.kafka:kafka-clients:$kafkaVersion"

        testImplementation("org.springframework.kafka:spring-kafka-test:$springKafkaVersion")
        testImplementation("org.apache.kafka:kafka_2.13:$kafkaVersion")
        testImplementation("org.apache.kafka:kafka_2.13:$kafkaVersion:test")
        testImplementation ("org.apache.kafka:kafka-clients:$kafkaVersion:test")

【问题讨论】:

  • 注意:如果 kafka-clients 已经被提及为编译的依赖项,则不需要将其作为测试依赖项

标签: scala spring-boot apache-kafka spring-kafka spring-kafka-test


【解决方案1】:

该接口仅存在于kafka_2.12 jars 中。

您似乎有一个 2.12 ...-test jar 和一个 2.13 kafka jar(这不是您的 gradle 所说的)。

gradle dependencies 说什么?

【讨论】:

  • 你是对的,group: 'io.findify', name: 's3mock_2.13 包含了 2.13 scala,我不得不降级它并且它起作用了。
猜你喜欢
  • 2017-03-06
  • 2017-02-25
  • 2016-07-03
  • 2017-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-18
  • 1970-01-01
  • 2020-01-02
相关资源
最近更新 更多