关于spark:Spark-javascala项目打包jar

36次阅读

共计 1101 个字符,预计需要花费 3 分钟才能阅读完成。

1. 法 1:maven 打包
pom.xml 文件

<plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <!-- 此处指定 main 办法入口的 class -->                      <mainClass>ch.kmeans2.SparkStreamingKMeansKafkaExample</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>assembly</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <version>2.15.2</version>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*.scala</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

而后应用 mvn clean package 命令进行打包,如果提交到集群运行遇到 Exception in thread “main” java.lang.AbstractMethodError,思考我的项目中 spark 的版本和集群运行版本是否始终
2. 法 2:idea 打包
Project->Module Setting->Artifacts



而后 Build Artifact 输入 jar 包

正文完
 0