看一下doc: http://spark.apache.org/docs/latest/submitting-applications.html#launching-applications-with-spark-submit
更具体地说,部分:
捆绑jar的路径,包括您的应用程序和所有依赖项。
而你的pom.xml清楚地表明你正在构建的jar没有依赖项。这就是为什么spark-submit找不到类kafka.serializer.StringDecoder。
您可能想要用来解决这个问题的是一个插件,它包含你的jar中的依赖项, maven组装 插件可以帮助你
如果您没有捆绑应用程序所需的所有依赖程序集,尝试构建包含所有依赖项的uber,通常会发生这种情况。
我添加了一部分样本pom文件,它将执行相同的操作。
<build> <sourceDirectory>src/main/scala</sourceDirectory> <plugins> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>3.1.6</version> <executions> <execution> <phase>compile</phase> <goals> <goal>compile</goal> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.3</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <shadedArtifactAttached>true</shadedArtifactAttached> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> <artifactSet> <includes> <include>*:*</include> </includes> </artifactSet> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>reference.conf</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins>
似乎complier无法找到kafka jar,因为你没有包含在pom文件中。 尝试在你的pom文件中添加以下依赖项。检查你正在使用的kafka版本。
<!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka_2.10 --> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_2.10</artifactId> <version>0.8.0</version> </dependency>