1 添加依赖
版本定义
<hbase.version>2.2.6</hbase.version>
<hadoop.version>3.2.0</hadoop.version>
<geomesa.version>3.3.0</geomesa.version>
引入依赖
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.locationtech.geomesa</groupId>
<artifactId>geomesa-hbase-datastore_2.11</artifactId>
<version>${geomesa.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-protocol</artifactId>
<version>${hbase.version}</version>
<!-- <scope>runtime</scope>-->
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
<version>${hbase.version}</version>
<!-- <scope>runtime</scope>-->
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>
<version>${hbase.version}</version>
<!-- <scope>runtime</scope>-->
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>${hbase.version}</version>
<!-- <scope>runtime</scope>-->
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-annotations</artifactId>
<version>${hbase.version}</version>
<!-- <scope>runtime</scope>-->
</dependency>
2 Java 实现
Map<String, Object> params = new HashMap<>();
params.put("hbase.catalog", "geomesa");
Configuration config = HBaseConfiguration.create();
config.set("hbase.rootdir", "hdfs://127.0.0.1:9000/hbase");
config.set("hbase.zookeeper.quorum", "127.0.0.1:2181");
config.set("zookeeper.znode.parent", "/hbase/master");
Connection connection = ConnectionFactory.createConnection(config);
params.put("hbase.connection",connection);
DataStore datastore = DataStoreFinder.getDataStore(params);
if (datastore == null) {
throw new RuntimeException("Could not create data store with provided parameters");
}