java.lang.NoClassDefFoundError:在kafka.utils.TestUtils.tempDirTestUtils.scala上的scala / collection / GenTraversableOnce

问题描述

使用@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

我的摇篮看起来像

            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_2.12个jar中。

您似乎以某种方式拥有一个2.12 ...-test罐子和一个2.13 kafka罐子(这不是您的gradle所说的)。

gradle dependencies怎么说?

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...