springboot+hbase 新增记录
1、先部署好 Hadoop
2、配置hbase
3、启动hbase
4、进入hbase shell
5、进入hbase shell 创建testtable
6、idea
表testtable 新增行记录 row1
1)、pom.xml
2)、HBaseTEST
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
import java.io.IOException;
public class HBaseTEST {
public static void main(String[] args) throws IOException {
Configuration configuration=HBaseConfiguration.create();
configuration.set("hbase.zookeeper.quorum","127.0.0.1");
HTable table=new HTable(configuration,"testtable");
Put put=new Put(Bytes.toBytes("row1"));
put.add(Bytes.toBytes("colfam1"),Bytes.toBytes("qual1"),Bytes.toBytes("val1"));
put.add(Bytes.toBytes("colfam1"),Bytes.toBytes("qual2"),Bytes.toBytes("val2"));
table.put(put);
}
}
3)、表testtable记录查询scan 如下
7、访问hbase