接前面的文章“
HbaseTemplate配置进阶:利用Spring自动装配加载HbaseTemplate
”1、java中的controller类:
@Controller
public class HbaseController {
@Autowired
private HbaseTemplate htemplate;
HbaseInit hbaseInit = new HbaseInit();
/*
*Hbase封装测试
**/
@RequestMapping(value = "/hbasetest.json", produces = "application/json; charset=UTF-8")
public void hbaseTest(HttpServletRequest request, HttpServletResponse response) throws Exception{
String tableName = "ns_sousuo:tdm_empower_gds_init_d";
String rowKey = "20160919_000000_ka_000000400_000000000";
String result = hbaseInit.getValueFromHbase(htemplate,tableName, rowKey);
System.out.println(result);
}
}