HbaseTemplate配置进阶:利用Spring自动装配加载HbaseTemplate
来源:互联网 发布:手机网络切换开关 编辑:程序博客网 时间:2024/06/14 20:00
1、spring-hbase.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hdp="http://www.springframework.org/schema/hadoop"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/hadoop
http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">
<!-- 加载外部的properties配置文件 -->
<context:property-placeholder location="file:/opt/search/resourse/hbase.properties"/>
<!-- 配置zookeeper的信息,远程连接hbase时使用 -->
<hdp:configuration resources="classpath:/hbase-site.xml" />
<hdp:hbase-configuration zk-quorum="${quorum}"
zk-port="${clientPort}" configuration-ref="hadoopConfiguration" />
<!-- 配置HbaseTemplate -->
<bean id="htemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate">
<property name="configuration" ref="hbaseConfiguration">
</property>
<property name="encoding" value="UTF-8"></property>
</bean>
</beans>
2、hbase-site.xml配置文件
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!-- zookeeper集群的URL配置
<property>
<name>hbase.zookeeper.quorum</name>
<value>namenode1-sit.cnsuning.com,namenode2-sit.cnsuning.com,slave01-sit.cnsuning.com</value>
</property> -->
<!-- 客户端连接端口
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2015</value>
</property> -->
<!-- 重试等待时间 -->
<property>
<name>hbase.client.pause</name>
<value>50</value>
</property>
<!-- 失败时重试次数 -->
<property>
<name>hbase.client.retries.number</name>
<value>3</value>
</property>
<!-- RPC请求的超时时间。如果某次RPC时间超过该值,客户端就会主动关闭socket -->
<property>
<name>hbase.rpc.timeout</name>
<value>2000</value>
</property>
<!-- HBase客户端发起一次数据操作直至得到响应之间总的超时时间 -->
<property>
<name>hbase.client.operation.timeout</name>
<value>3000</value>
</property>
<!-- 该参数是表示HBase客户端发起一次scan操作的rpc调用至得到响应之间总的超时时间 -->
<property>
<name>hbase.client.scanner.timeout.period</name>
<value>10000</value>
</property>
</configuration>
3、hbase.properties属性配置文件
quorum=10.16.35.232
clientPort=2015
4、applicationContext.xml配置文件
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:hdp="http://www.springframework.org/schema/hadoop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd">
<context:component-scan base-package="com.suning" />
<context:component-scan base-package="com.suning.app" />
<context:component-scan base-package="com.suning.commonlib" />
<context:component-scan base-package="com.suning.snRedis" />
<import resource="classpath:/spring-hbase.xml" /> <!--关键这里,直接引用外部的xml文件-->
</beans>
4、java中调用只需
@Autowired
HbaseTemplate htemplate;
- HbaseTemplate配置进阶:利用Spring自动装配加载HbaseTemplate
- HbaseTemplate配置进阶:利用Spring自动装配加载HbaseTemplate
- spring hbase hbaseTemplate
- 使用spring-hbaseTemplate过滤器
- HbaseTemplate进阶:利用hbase.properties文件对Hbase的集群和端口进行配置
- HbaseTemplate进阶:利用hbase.properties文件对Hbase的集群和端口进行配置
- 手动封装HbaseTemplate mapper类
- java 获取 hbase数据 springdatahadoop -- hbasetemplate
- maven+springmvc+hbaseTemplate java.lang.AbstractMethodError
- java 获取 hbase数据 springdatahadoop -- hbasetemplate
- spring 配置bean-自动装配
- Spring XML配置自动装配的Bean
- spring配置bean中的自动装配
- Spring 配置使用 - Bean 自动装配
- spring-xml配置bean自动装配
- Spring配置组件扫描和自动装配
- Spring Bean装配-自动装配
- Spring之利用autowire属性进行自动装配
- java数值型
- Mysql You can change this value on the server by setting the max_allowed_packet' variable. 异常
- "PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You
- 新博客地址
- 线程池作用及Executors方法讲解
- HbaseTemplate配置进阶:利用Spring自动装配加载HbaseTemplate
- docker 基本命令大全
- [转]高压缩空间占用的 Hyper LogLog 算法
- java(1)基本规范
- stm32_HAL库中__weak修饰符
- JAVA中的强引用、软引用(SoftReference)、弱引用(WeakReference)和幽灵引用(PhantomReference)
- SaaS存在怎样的隐忧?
- 深入分析Mysql中limit的用法
- Copy-On-Write容器