{"id":25490234,"url":"https://github.com/al-assad/spring-data-hbase","last_synced_at":"2026-04-27T16:31:13.334Z","repository":{"id":105548996,"uuid":"213330731","full_name":"Al-assad/spring-data-hbase","owner":"Al-assad","description":"spring-data-hadoop 中的 hbase 代码部分提取，支持 hbase 2.x API","archived":false,"fork":false,"pushed_at":"2019-10-07T10:31:21.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-18T23:35:02.795Z","etag":null,"topics":["hbase","hbasetemplate","spring","spring-data","spring-data-hbase"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Al-assad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-07T08:25:41.000Z","updated_at":"2021-03-15T08:37:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"ddc575ba-b5f5-4963-8e02-69cf0d861677","html_url":"https://github.com/Al-assad/spring-data-hbase","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Al-assad/spring-data-hbase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Al-assad%2Fspring-data-hbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Al-assad%2Fspring-data-hbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Al-assad%2Fspring-data-hbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Al-assad%2Fspring-data-hbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Al-assad","download_url":"https://codeload.github.com/Al-assad/spring-data-hbase/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Al-assad%2Fspring-data-hbase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32345802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hbase","hbasetemplate","spring","spring-data","spring-data-hbase"],"created_at":"2025-02-18T21:27:37.044Z","updated_at":"2026-04-27T16:31:13.328Z","avatar_url":"https://github.com/Al-assad.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring-Data-Hbase\n\nspring-data-hadoop 项目 HBaseTemplate API 提取，支持 HBase 2.x API\n\n\u003cbr\u003e\n\n## 项目说明\n\n由于 [spring-data-hadoop](https://spring.io/projects/spring-boot) 目前已经停止更新（2019-04-05），最后一个版本不支持 Hbase-Client-2.x 的 API，此项目基于 [spring-hadoop](https://github.com/Al-assad/spring-data-hbase) 代码，提取 spring-data-hbase 部分的代码，更新相关代码以支持 HBase 2.x。\n\n该项目引入的主要组件依赖版本如下：\n\n* spring-boot：2.1.8.RELEASE\n\n* hbase-client：2.0.0\n\n实际使用可以根据实际版本修改 pom 并重新打包；\n\n\u003cbr\u003e\n\n## HBase 连接配置\n\nspring-data-hbase 已经集成了 spring-boot 的 auto configuration 功能，自动读取 yml 或者 properties 中以 `spring.data.hbase.config`  为前缀的配置项，作为 hbase 的连接配置项，以下是一个示例的 yml 配置文件：\n\n```yaml\nspring.data.hbase.config:\n    hbase.zookeeper.quorum: hbase\n    hbase.zookeeper.property.clientPort: 2181\n    hbase.zookeeper.parent: /hbase\n    hbase.rootdir: hdfs://namenode:9000/hbase\n```\n\n\u003cbr\u003e\n\n## HBaseTemplate 使用说明\n\nHBaseTemplate 的使用和原生 HBaseTemplate API 完全一致，所有的测试代码位于 `/src/test`  目录下，以下作简要说明：\n\n### 示例用的 HBase 初始化语句\n\n```\ncreate 'city', 'f0'\n```\n\n### 映射用的 DTO 实体\n\n```java\n\npublic class CityDTO {\n    private String rowkey;\n    private String name;\n    private String province;\n    private String code;\n    .......\n }\n```\n\n### HBase Put 操作\n\n```java\n/**\n * 新增/更新数据\n */\n@Test\npublic void testPut() {\nhbaseTemplate.execute(\"city\", (TableCallback\u003cObject\u003e) table -\u003e {\n    String rowkey = \"key122\";\n    Put put = new Put(Bytes.toBytes(rowkey));\n    put.addColumn(Bytes.toBytes(\"f0\"), Bytes.toBytes(\"name\"), Bytes.toBytes(\"guangzhou\"));\n    put.addColumn(Bytes.toBytes(\"f0\"), Bytes.toBytes(\"province\"), Bytes.toBytes(\"guangdong\"));\n    put.addColumn(Bytes.toBytes(\"f0\"), Bytes.toBytes(\"code\"), Bytes.toBytes(\"G-11\"));\n    table.put(put);\n    return rowkey;\n});\n}\n\n/**\n * 删除数据\n */\n@Test\npublic void testDelete() {\nhbaseTemplate.execute(\"city\", (TableCallback\u003cObject\u003e) table -\u003e {\n    String rowkey = \"key122\";\n    Delete delete = new Delete(Bytes.toBytes(rowkey));\n    table.delete(delete);\n    return rowkey;\n});\n}\n```\n\n#### HBase Get/Scan 操作\n\n```java\n/**\n * get 操作\n */\n@Test\npublic void testGet() {\nString rowkey = \"key122\";\nCityDTO results = hbaseTemplate.get(\"city\", rowkey, (result, rowNum) -\u003e {\n    CityDTO dto = new CityDTO.CityDTOBuilder()\n            .rowkey(new String(result.getRow()))\n            .name(new String(result.getValue(Bytes.toBytes(\"f0\"), Bytes.toBytes(\"name\"))))\n            .province(new String(result.getValue(Bytes.toBytes(\"f0\"), Bytes.toBytes(\"province\"))))\n            .code(new String(result.getValue(Bytes.toBytes(\"f0\"), Bytes.toBytes(\"code\"))))\n            .build();\n    return dto;\n});\nSystem.out.println(results);\n}\n\n/**\n * scan 操作\n */\n@Test\npublic void testScanFilter() {\nScan scan = new Scan().withStartRow(Bytes.toBytes(\"key100\")).withStopRow(Bytes.toBytes(\"key300\"));\nscan.addFamily(Bytes.toBytes(\"f0\"));\nscan.setFilter(new SingleColumnValueFilter(\n        Bytes.toBytes(\"f0\"),\n        Bytes.toBytes(\"code\"),\n        CompareOperator.EQUAL,\n        Bytes.toBytes(\"G-11\")));\n\nList\u003cCityDTO\u003e results = hbaseTemplate.find(\"city\", scan, (result, rowNum) -\u003e {\n    CityDTO dto = new CityDTO.CityDTOBuilder()\n            .rowkey(new String(result.getRow()))\n            .name(new String(result.getValue(Bytes.toBytes(\"f0\"), Bytes.toBytes(\"name\"))))\n            .province(new String(result.getValue(Bytes.toBytes(\"f0\"), Bytes.toBytes(\"province\"))))\n            .code(new String(result.getValue(Bytes.toBytes(\"f0\"), Bytes.toBytes(\"code\"))))\n            .build();\n    return dto;\n});\nresults.forEach(System.out::println);\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fal-assad%2Fspring-data-hbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fal-assad%2Fspring-data-hbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fal-assad%2Fspring-data-hbase/lists"}