Spring Boot 项目访问hbase 编译遇到 java.io.FileNotFoundException: HADOOP_HOME and hadoop.home.dir are unset

在window 10 系统下,使用idea创建了一个spring boot 项目,并使用hbase-client 接口访问hbase(hbase 在WSL 子系统启动),在编译的时候,遇到如下错误:

 

根据提示,打开链接:https://cwiki.apache.org/confluence/display/HADOOP2/WindowsProblems (原来的链接地址已经移动到新地址了),如下对问题的描述:

Problems running Hadoop on Windows

Hadoop requires native libraries on Windows to work properly -that includes to access the file:// filesystem, where Hadoop uses some Windows APIs to implement posix-like file access permissions.

This is implemented in HADOOP.DLL and WINUTILS.EXE.

In particular, %HADOOP_HOME%\BIN\WINUTILS.EXE must be locatable.

If it is not, Hadoop or an application built on top of Hadoop will fail.
How to fix a missing WINUTILS.EXE

You can fix this problem in two ways

    Install a full native windows Hadoop version. The ASF does not currently (September 2015) release such a version; releases are available externally.
    Or: get the WINUTILS.EXE binary from a Hadoop redistribution. There is a repository of this for some Hadoop versions on github.

Then

    Set the environment variable %HADOOP_HOME% to point to the directory above the BIN dir containing WINUTILS.EXE.
    Or: run the Java process with the system property hadoop.home.dir set to the home directory.

 

提示需要设置HADOOP_HOME 环境变量,并下载相应的HADOOP.DLL and WINUTILS.EXE,于是打开wiki 中的Git,找到相应版本的hadoop,并下载这2个文件到本地目录,

因本地也下载了spark,把这2个文件保存到 C:\Application\spark-3.2.0-bin-hadoop3.2-scala2.13\bin 目录,添加环境变量 HADOOP_HOME, 并在Path 变量里添加路径:%HADOOP_HOME%\bin, 保存变量

 

 

重新打开idea,并编译项目,错误消失

posted @ 2022-09-06 10:27  黎明踏浪号  阅读(930)  评论(0编辑  收藏  举报