1.打开pom.xml文件添加以下内容
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin </artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.atguigu.mr.wordcount.WordcountDriver</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
2.将代码中mainClass标签内容更换成自己的主类的Qualified name,然后保存
3.如果项目有小红叉右键找到Maven→updata project单击
4.对自己的项目右键找到run as→Maven install单击,然后刷新
5.将target下的jar包上传到集群
6.执行命令
hadoop jar /你的jar包路径/name.jar 主类的Qualifiedname /待执行文件路径 /输出路径
注意:输出路径要为空