Environment:Win764biteclipse version:kepler Service Release 1java Version "1.7.0_40"
First step:Create a new MAVEN project in Eclipse, edit the Pom.xml and update the download jar package <project xmlns=
"http://maven.apache.org/POM/4.0.0" xmlns:xsi=
"Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/ Maven-4.0.0.xsd "> <modelversion>4.0.0</modelversion> <groupId>fulong.bigdata</groupId> <artifactid>myhbase</artifactid> <version>0.0.1-snapshot</version> <dependencies> <dependency> <groupId>org.apache.hbase</groupId> <artifactid>
hbase-client</artifactid> <version>0.96.2-hadoop2</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactid>
hadoop-hdfs</artifactid> <version>2.2.0</version> </dependency> <dependency> <groupId>jdk.tools</groupId> <artifactid>jdk.tools</artifactid> <version>1.7</version> <scope>system</scope> <systempath>${java_home}/lib/tools.jar</systempath> </dependency> </dependencies> </Project>
Step Two:The
target cluster's
Hadoop and HBase
configuration files are copied to the projectThe goal is to enable the project to find zookeeper and HBase Master. The path to the configuration file in the project is:/src/main/resources/hadoop
/src/main/resources/hbase
The two directories are then added to the classpath of the project:
The final directory structure is as follows:
Step Three: Add in Hbase-site.xml
<property > <name>fs.hdfs.impl</name> <value>
org.apache.hadoop.hdfs.DistributedFileSystem</value> </property >
Fourth Step:
Write Java program invoke HBase interfaceThis code contains some of the commonly used hbase interfaces.