错误内容如下
20/03/13 15:21:20 ERROR ApplicationMaster: User class threw exception: java.lang.NoClassDefFoundError: org/apache/kafka/clients/consumer/Consumer java.lang.NoClassDefFoundError: org/apache/kafka/clients/consumer/Consumer at org.apache.spark.streaming.kafka010.ConsumerStrategies$.Subscribe(ConsumerStrategy.scala:256) at com.znv.facecluster.utils.SparkUtils$.getStreamFormKafka(SparkUtils.scala:40) at com.znv.facecluster.topic.FaceClusterTopic$.readPicture(FaceClusterTopic.scala:37) at com.znv.facecluster.topic.FaceClusterTopic$.process(FaceClusterTopic.scala:28) at com.znv.facecluster.entry.RealTimeFaceClusterApp$.main(RealTimeFaceClusterApp.scala:76) at com.znv.facecluster.entry.RealTimeFaceClusterApp.main(RealTimeFaceClusterApp.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$4.run(ApplicationMaster.scala:721) Caused by: java.lang.ClassNotFoundException: org.apache.kafka.clients.consumer.Consumer at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 11 more
解决办法:--jars 添加kafka-clients-0.10.0.1.jar(版本根据需要修改)