idea中用spark 编写wordcount报错问题和应对措施汇总

此文章是博主自己在idea中用spark 编写wordcount时出现的报错,以及采取的解决办法,在寻找解决办法时寻求了网络的帮助,仅供学习参考使用,不作他用

问题:Did not find winutils.exe: {}

21/12/06 22:38:58 WARN Shell: Did not find winutils.exe: {}
java.io.FileNotFoundException: Could not locate Hadoop executable: D:\main\hadoop-3.1.3\bin\winutils.exe -see https://wiki.apache.org/hadoop/WindowsProblems
at org.apache.hadoop.util.Shell.getQualifiedBinInner(Shell.java:620)
at org.apache.hadoop.util.Shell.getQualifiedBin(Shell.java:593)
at org.apache.hadoop.util.Shell.(Shell.java:690)
at org.apache.hadoop.util.StringUtils.(StringUtils.java:78)
​
原因:非程序的错误,而是windows系统用到lhadoop相关的服务

解决方法:通过配置关联到windows的系统依赖

因为用的是hadoop 3.1.3版本,但是在github上没有,所以可以取相近的版本3.1.2,由于github比较慢,这里就使用的Gitee。到这里边下载地址去下载里边的winutils.exehadoop.dll文件,并放到你安装目录下的bin目录下

同时需要配置系统变量

在这里插入图片描述

其他方法:

上述进行修补的操作,目前有部分的API会出现兼容问题,这里建议换成hadoop 3.1.2,本文发表的这个时间github上并没有3.1.3相关的包,使用3.1.2也是差不多

问题:

Exception in thread "main" java.lang.IllegalAccessError:tried to access method com.google.common.base.Stopwatch.<init>()V from class org.apache.hadoop.mapre

解决:在pom.xml(spark-core)中添加下面代码

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-common</artifactId>
    <version>${hadoop.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-mapreduce-client-core</artifactId>
    <version>${hadoop.version}</version>
</dependency>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值