1.在IDEA 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.yy.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>
注意:代码中mainClass需要根据打包的具体类修改
2.在IDEA右侧栏中选择Maven Projects,打开Lifecycle文件夹,先点击compile再点击package,等待jar包完成。
jar包打完之后打开左侧target文件夹,发现有两个jar包,把无依赖的jar包复制到虚拟机的hadoop文件夹下
3.在虚拟机hadoop文件夹下输入
hadoop far +jar包名称 +mainClass + 输入路径 + 输出路径
4.打开50070端口,在输出路径下载结果,成功
原文地址:https://www.cnblogs.com/yaoyu19960106/p/10493804.html
时间: 2024-11-08 22:01:51