实现远程访问HBase,可以通过Eclipse开发工具方便进行代码调试。

为了方便jar包各种版本的管理,才用maven进行代码构建

首先,下载并安装maven以及M2Eclipse插件

其次,配置maven的pom.xml文件,加入如下依赖

<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>1.0.0-cdh5.4.0</version>
</dependency>

以及资源获取配置信息

<repositories>
<repository>
<id>cloudera-releases</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

 

关于使用JAVA的版本,可以利用如下进行设置(本文采用1.8以上的版本)

 

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

 

接下来,用maven生成eclipse工程(maven eclipse:eclipse)

部署中发现以下问题:

1. No FileSystem for scheme: hdfs

网上从常用做法:
I added the following to my core-site.xml and it worked:

<property>
   <name>fs.file.impl</name>
   <value>org.apache.hadoop.fs.LocalFileSystem</value>
   <description>The FileSystem for file: uris.</description>
</property>

<property>
   <name>fs.hdfs.impl</name>
   <value>org.apache.hadoop.hdfs.DistributedFileSystem</value>
   <description>The FileSystem for hdfs: uris.</description>
</property>
但是使用后发现org.apache.hadoop.hdfs反射找不到相关类,于是在maven里
增加如下的依赖:

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.6.0-cdh5.4.0</version>
</dependency>

2. 发现hbase-site.xml文件一直没有被读取,需要采用如下步骤:
将hbase-site.xml添加到eclipse中,添加方法,在eclipse中创建一个文件夹,与src同级,然后将hbase-site.xml复制到conf下

右击项目,build path  -----configuter build path-------liberary  ----add class forder,选择conf。

 

3. 要在eclipse使用的机器的hosts里边加上使用到的各个regionserver的域名

相关文章:

  • 2021-12-06
  • 2021-10-24
  • 2022-03-07
  • 2021-12-09
  • 2021-10-19
  • 2021-11-27
  • 2021-05-09
  • 2021-04-20
猜你喜欢
  • 2021-11-30
  • 2021-08-24
  • 2021-10-18
  • 2022-01-18
  • 2022-12-23
  • 2021-12-19
  • 2022-02-17
相关资源
相似解决方案