sbt scala中的java.lang.ClassNotFoundException 2.11 IntelliJ IDEA sbt 1.0

时间:2018-04-26 05:35:28

标签: scala apache-spark apache-kafka

我在IntelliJ IDEA中为spark.streaming.kafka执行了Scala代码,其中我使用的是scala版本2.11,sbt 1.0和spark版本2.0.1

我正在尝试通过Kafka制作人发送消息并尝试获取spark集群我在spark集群中执行了以下命令:

bin/spark-submit --packages org.apache.spark:spark-streaming-kafka-0- 
10_2.11:2.0.1 --class "KafkaWordCount" --master 
spark://bluedata5.bdlocal:7077 jars/sskafka_2.11-0.1.jar localhost:2080 
sds_test

代码: KafkaWordCount.scala

enter image description here

Build.sbt

enter image description here

错误: 输出1

enter image description here

输出2

enter image description here

请帮我解决错误

1 个答案:

答案 0 :(得分:1)

错误信息足够清楚,表示

  
    

java.lang.ClassNotFoundException:KafkaWordCount

  

您所要做的就是提供 KafkaWordCount类的完整padkage路径,即kafspa.KafkaWordCount

所以你的spark-submit命令应该是

bin/spark-submit --packages org.apache.spark:spark-streaming-kafka-0-10_2.11:2.0.1 --class kafspa.KafkaWordCount --master spark://bluedata5.bdlocal:7077 jars/sskafka_2.11-0.1.jar localhost:2080 sds_test