分化不多说直接上内容,在pom文件中加入以下内容完美解决这个问题
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!----------若干其他东西-------------->
<modules>
<!----------若干其他东西-------------->
</modules>
<properties>
<!----------若干其他东西-------------->
</properties>
<dependencies>
<!----------若干其他东西-------------->
</dependencies>
<!-- build标签 常用于添加插件及编译配置 -->
<build>
<!-- 编译配置 指定finalName用于指定打包的包名 -->
<finalName>Spark-worldCount</finalName>
<plugins>
<plugin>
<!-- Apache Maven Shade Plugin依赖 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<!-- 打包执行目标 -->
<executions> <execution> <phase>package</phase> <goals><goal>shade</goal></goals>
<configuration><transformers>
<!-- 打成可执行的jar包 的主方法入口-->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries> <Main-Class>WorldCount</Main-Class> </manifestEntries>
</transformer>
</transformers></configuration>
</execution> </executions>
</plugin>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>