Srping is familiar to java web programmers and jdbcTemplate. Let's take a look at the Spring-data-hadoop project, a new member of the Spring family. The Spring-hadoop project should be part of the Spring Data Project (the REST of the Srping data includes combining Spring with JDBC, REST, and mainstream NoSQL ). In fact, what happens when Spring and Hadoop are combined is to unify the configuration of Hadoop components, task deployment, and other things into Spring bean management.
The procedure is as follows:
1. Download and import the required jar package:
2. Configure web. xml:
contextConfigLocation classpath:beans.xml org.springframework.web.context.ContextLoaderListener org.springframework.web.util.IntrospectorCleanupListener login.jsp
3. Configure beans. xml:
4. Copy the hbase-site.xml configuration file to the src directory. The reference content is as follows:
hbase.rootdir hdfs://nameservice1/hbase hbase.client.write.buffer 62914560 hbase.client.pause 1000 hbase.client.retries.number 10 hbase.client.scanner.caching 1 hbase.client.keyvalue.maxsize 62914560 hbase.rpc.timeout 60000 hbase.security.authentication simple zookeeper.session.timeout 60000 zookeeper.znode.parent /hbase zookeeper.znode.rootserver root-region-server hbase.zookeeper.quorum xinhong-hadoop-56,xinhong-hadoop-52,xinhong-hadoop-53 hbase.zookeeper.property.clientPort 2181
5. hbase template demo:
Query the data of columns in the column family:
List<String> List<String> rows = hbaseTemplate.find(tableName, family,cloumn, RowMapper<String> String mapRow(Result result, rowNum) }
Query a data column of a specified row key:
String context = hbaseTemplate.get(tableName, "NCEP_p_wa_2014032212_tp_006.nc", family, cloumn, RowMapper<String> String mapRow(Result result, rowNum) }
PS: For details about how to use the RowMapper callback function, refer to http://www.cnblogs.com/zhangyukun/p/4265).html.