java三 hbase 和 Properties

https://www.zifangsky.cn/1286.html      hbase2.0 springboot操作

https://blog.csdn.net/l_lushuang/article/details/69551116     hbase HbaseTemplate使用方式

https://www.cnblogs.com/520future/p/8482014.html    properties的基本用法

@RequestMapping(value=”/hbase”, method=RequestMethod.GET)
public Map<String,String> thbase(){
hbaseService.putData(“image”,”imageid03″,”user”,new String[]{“project_id”,”varName”,”coefs”,”pvalues”,”tvalues”,”create_time”},new String[]{“40866″,”mob_3″,”0.9416″,”0.0000″,”12.2293″,”null”});

Map<String,String> result1 = hbaseService.getRowData(“image”,”imageid03″);
System.out.println(“+++++++++++根据rowKey查询+++++++++++”);
result1.forEach((k,value) -> {
System.out.println(k + “—” + value);
});
System.out.println();
return result1;

}

 

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-hadoop-boot</artifactId>
<version>2.5.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-hadoop</artifactId>
<version>2.5.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>2.0.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.11.0</version>
</dependency>

 

package com.aijava.app.hbase;

import com.aijava.app.hbase.HBaseService;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;
import java.io.InputStream;
import java.io.FileInputStream;

/**
* HBase相关配置
*
* @author zifangsky
* @date 2018/7/12
* @since 1.0.0
*/
@Configuration
public class HBaseConfig {
@Value(“${HBase.nodes}”)
private String nodes;

@Value(“${HBase.maxsize}”)
private String maxsize;

@Bean
public HBaseService getHbaseService(){
org.apache.hadoop.conf.Configuration conf = HBaseConfiguration.create();
// conf.set(“hbase.client.keyvalue.maxsize”,maxsize);
// conf.set(“hbase.zookeeper.quorum”,nodes);
try {
Properties prop = new Properties();
String path = Thread.currentThread().getContextClassLoader().getResource(“”).getPath();
InputStream is = new FileInputStream(path + “/application.properties”);
prop.load(is);
conf.set(“hbase.client.keyvalue.maxsize”,prop.getProperty(“HBase.maxsize”));
conf.set(“hbase.zookeeper.quorum”,prop.getProperty(“HBase.nodes”));
} catch (Exception e) {
e.printStackTrace();
}

return new HBaseService(conf);
}
}

 

hbase

docker.io/harisekhon/hbase 2.1

docker run -it -d --name hbase -p 16010:16010 -p 9090:9090 -v /opt/data/hbase:/hbase-data harisekhon/hbase:2.1


pip install thrift   happybase

https://www.csdn.net/gather_28/MtTaEgysMjY1My1ibG9n.html