异常日志
2021-03-05 11:57:16.902 tid: [main] WARN org.apache.hadoop.util.Shell -
Did not find winutils.exe: {}
java.io.FileNotFoundException: java.io.FileNotFoundException: HADOOP_HOME and hadoop.home.dir are unset. -see https://wiki.apache.org/hadoop/WindowsProblems
at org.apache.hadoop.util.Shell.fileNotFoundException(Shell.java:548)
at org.apache.hadoop.util.Shell.getHadoopHomeDir(Shell.java:569)
at org.apache.hadoop.util.Shell.getQualifiedBin(Shell.java:592)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:689)
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:78)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:3609)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:3604)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:3441)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:524)
at org.puppy.hadoop.app.HDFSApplication.main(HDFSApplication.java:26)
Caused by: java.io.FileNotFoundException: HADOOP_HOME and hadoop.home.dir are unset.
at org.apache.hadoop.util.Shell.checkHadoopHomeInner(Shell.java:468)
at org.apache.hadoop.util.Shell.checkHadoopHome(Shell.java:439)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:516)
... 6 common frames omitted
原因是因为缺少一些hadoop支持,需要下载一些资源配置之后才能使用。下载地址
(1):将文件解压到任意目录下
(2):将hadoop.dll复制到C:\Window\System32下(这一步最重要,找了很多文章,都没说这个,然后就还是一直不成功)
(3):添加环境变量HADOOP_HOME,指向hadoop目录(你解压的目录)
(4):将%HADOOP_HOME%\bin加入到path里面
(5):重启 IDE(我的没重启就出问题了,主要是因为环境变量修改了,需要重启启动idea进程读取环境变量)
(6). 再次运行你的程序就不会在看到这个异常。
网友评论