SBT IntegrationTest依赖项缺少类定义

时间:2018-07-27 17:38:52

标签: spring apache-kafka sbt integration-testing

我正在尝试在我的sbt项目la this guide中设置集成测试配置。集成测试配置将与sbt it:test一起运行,以测试我们与spring embedded kafka server的集成。这是相关的sbt代码:

libraryDependencies ++= Seq(
  "com.novocode" % "junit-interface" % "0.11",
  "org.apache.kafka" % "kafka-clients" % kafkaVersion,
  "org.apache.kafka" % "kafka-clients" % kafkaVersion,
  "org.apache.kafka" % "kafka-streams" % kafkaVersion,
  "org.mockito" % "mockito-all" % "1.10.19"
).map(_ % "it,test"
  exclude("org.springframework.boot","spring-boot-starter-logging"))

libraryDependencies ++= Seq(
  "org.springframework.kafka" % "spring-kafka-test" % springKafkaVersion,
  "org.springframework.boot" % "spring-boot-starter-test" % springBootVersion
).map(_ % "it"
  exclude("org.springframework.boot","spring-boot-starter-logging"))

lazy val root = (project in file("."))
  .configs(IntegrationTest)
  .settings(Defaults.itSettings, projectDependencies := {Seq()})

我的项目结构是:

/src
    /it
        /java
            ... it test code ...
        /resources
            ... it test resources ...
    /main

编译成功完成,并启动测试。但是,每个集成测试都以

失败
java.lang.NoClassDefFoundError: Could not initialize class kafka.utils.TestUtils$, took 0.1 sec
[error]     at kafka.zk.EmbeddedZookeeper.<init>(EmbeddedZookeeper.scala:29)
[error]     at org.springframework.kafka.test.rule.KafkaEmbedded.startZookeeper(KafkaEmbedded.java:347)
[error]     at org.springframework.kafka.test.rule.KafkaEmbedded.before(KafkaEmbedded.java:185)

at the reported line是org.apache.zookeeper软件包中的ZooKeeperServer。此类在spring-kafka-test的依赖项层次结构中:

spring-kafka-test > kafka_2.11 > zookeeper

有人知道为什么我无法解决这种依赖性吗?

0 个答案:

没有答案