无法解析符号hbase

问题描述 投票:0回答:1

我是HBase的新手,我从互联网上复制了一个示例Java代码,但是在构建此示例时遇到了错误[[“无法解析符号HBase”。我使用Gradle构建此示例项目,并使用Intellij作为IDE。 HBase服务器是一个远程服务器,我尝试在Windows笔记本电脑上编写一个put示例来测试HBase,但是我对HBase和Gradle并不熟悉,是否有人可以提出一些我错过的建议?这是我的代码

import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.util.Bytes; public class PutHbaseClient { public static void main(String[] args) throws IOException { Configuration conf = HBaseConfiguration.create(); Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(TableName.valueOf("test")); try { /* * Put operations for a single row. To perform a * Put, instantiate a Put object with the row to insert to and for * each column to be inserted, execute addcolumn. */ Put put1 = new Put(Bytes.toBytes("row1")); Put put2 = new Put(Bytes.toBytes("row2")); Put put3 = new Put(Bytes.toBytes("row3")); put1.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("qual1"), Bytes.toBytes("ValueOneForPut1Qual1")); put2.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("qual1"), Bytes.toBytes("ValueOneForPut2Qual1")); put3.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("qual1"), Bytes.toBytes("ValueOneForPut2Qual1")); put1.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("qual2"), Bytes.toBytes("ValueOneForPut1Qual2")); put2.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("qual2"), Bytes.toBytes("ValueOneForPut2Qual2")); put3.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("qual2"), Bytes.toBytes("ValueOneForPut3Qual3")); table.put(put1); table.put(put2); table.put(put3); } finally { table.close(); connection.close(); } } }
这是我的build.gradle

plugins { id 'java' } group 'gid' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies { compile group: 'org.apache.hadoop', name: 'hadoop-common', version:'2.7.3' testCompile group: 'junit', name: 'junit', version: '4.12' }

java hadoop intellij-idea hbase
1个回答
0
投票
我认为您在gradle依赖项中需要这样的东西:

compile 'org.apache.hbase:hbase:3.0.0-SNAPSHOT'

© www.soinside.com 2019 - 2024. All rights reserved.