如何查找每个kafka版本需要使用哪个scala版本

时间:2014-08-05 07:28:18

标签: spring maven scala-2.8 apache-kafka

目前我们正在使用kafka-0.7.2(https://clojars.org/org.clojars.paul/core-kafka_2.8.0)和scala版本2.8.0。

我们很高兴看到kafka 0.8.1.1,所以我们在提到的博客中遵循了生产者(https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+Producer+Example)代码和消费者(https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example)代码。

此代码导致缺少scala.serializer类的错误,因此我搜索并获得scala-2.10.3(Eclipse scala.object cannot be resolved)将解决此问题的信息。

再次运行此代码时出现错误

[WARNING] 
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
        at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoClassDefFoundError: scala/reflect/ClassManifest
        at kafka.utils.Log4jController$.<init>(Log4jController.scala:29)
        at kafka.utils.Log4jController$.<clinit>(Log4jController.scala)
        at kafka.utils.Logging$class.$init$(Logging.scala:29)



will linger despite being asked to die via interruption
[WARNING] NOTE: 3 thread(s) did not finish despite being asked to  via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=packageName,maxpri=10]
java.lang.IllegalThreadStateException
        at java.lang.ThreadGroup.destroy(ThreadGroup.java:775)
        at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:328)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)

我不知道为什么会发生这个错误,

更改了pom.xml

<dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.9.2</artifactId>
            <version>0.8.1.1</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.10.3</version>
        </dependency>

我也从网站上获得了一个信息,kafka 0.8.1.1将支持不同版本的scala,但我不知道为什么它不支持这个scala版本(2.10.3)。

How can we find for  x kafka version, y scala version will work

我也想到了kafka-0.8.1.1的gradle.properties

group=org.apache.kafka
version=0.8.1.1
scalaVersion=2.8.0
task=build

这里提到的2.8.0的scalaVersion是用于?

提前致谢

1 个答案:

答案 0 :(得分:0)

我已经删除了scala依赖项,因为它在内部使用了scala。现在它正常工作,并且还对zookeeper连接的属性名称进行了一些更改。