编译jar项目Maven Eclipse时出错

时间:2018-07-11 11:59:13

标签: java maven apache-kafka

我正在尝试从github(https://github.com/kafka-dev/kafka/tree/master/examples/src/main/java/kafka/examples)的kafka示例中编译jar项目

设置环境和所有组件(Kafka 2.11-1.1.0和zookeeper,创建一个主题并更改所有属性的东西)之后,该项目实际上在Eclipse Eclipse中使用Maven 3.3.9取得了成功。尝试java -jar *******。jar我收到以下错误。

    Exception in thread "main" java.lang.NoClassDefFoundError: kafka/utils/ShutdownableThread
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.apache.apex.examples.kafka.kafka2hdfs.TestConsumer.main(TestConsumer.java:22)
Caused by: java.lang.ClassNotFoundException: kafka.utils.ShutdownableThread
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

这是TestConsumer.java

package org.apache.apex.examples.kafka.kafka2hdfs;

public class TestConsumer {
    public static void main(String[] args) {

        Consumer consumerThread = new Consumer(KafkaProperties.TOPIC);
        consumerThread.start();
        System.out.println("ok");
    }
}

0 个答案:

没有答案