Spring RedisTemplate操作-xml配置(1)
网上没能找到全的spring redistemplate操作例子,故特意化了点时间做了接口调用练习,基本包含了所有redistemplate方法。
该操作例子是个系列,该片为spring xml配置,方便后面做各个数据类型的操作。
Redis是一个开源(BSD许可),内存存储的数据结构服务器,可用作数据库,高速缓存和消息队列代理。它支持字符串、哈希表、列表、集合、有序集合,位图,hyperloglogs等数据类型。内置复制、Lua脚本、LRU收回、事务以及不同级别磁盘持久化功能,同时通过Redis Sentinel提供高可用,通过Redis Cluster提供自动分区。
<context:annotation-config /> <!-- 把非@Controller注解的类转换为bean -->
<context:component-scan base-package="tk.tankpao" /> <cache:annotation-driven /> <context:property-placeholder
location="classpath:conf/properties/redis.properties" /> <aop:aspectj-autoproxy proxy-target-class="true"/> <!-- jedis 配置 -->
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="${redis.maxIdle}" />
<property name="maxWaitMillis" value="${redis.maxWait}" />
<property name="maxTotal" value="${redis.maxActive}" />
<property name="testOnBorrow" value="${redis.testOnBorrow}" />
</bean> <!-- redis服务器中心 -->
<bean id="redisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="poolConfig" ref="poolConfig" />
<property name="port" value="${redis.port}" />
<property name="hostName" value="${redis.host}" />
<property name="password" value="${redis.password}" />
<property name="timeout" value="${redis.timeout}"></property>
</bean> <bean id="redisTemplate" name="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="redisConnectionFactory" />
<property name="keySerializer" ref="stringRedisSerializer" />
<property name="valueSerializer" ref="stringRedisSerializer" />
<property name="hashKeySerializer" ref="stringRedisSerializer" />
<property name="hashValueSerializer" ref="jackson2JsonRedisSerializer" />
<!-- <property name="enableTransactionSupport" value="true"/> -->
</bean> <bean id="jdkredisTemplate" name="jdkredisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="redisConnectionFactory" />
<property name="keySerializer" ref="jdkSerializationRedisSerializer" />
<property name="valueSerializer" ref="jdkSerializationRedisSerializer" />
<property name="hashKeySerializer" ref="stringRedisSerializer" />
<property name="hashValueSerializer" ref="jackson2JsonRedisSerializer" />
</bean> <bean id="jacksonredisTemplate" name="jacksonredisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="redisConnectionFactory" />
<property name="keySerializer" ref="jackson2JsonRedisSerializer" />
<property name="valueSerializer" ref="jackson2JsonRedisSerializer" />
<property name="hashKeySerializer" ref="stringRedisSerializer" />
<property name="hashValueSerializer" ref="jackson2JsonRedisSerializer" />
</bean> <bean id="stringRedisSerializer"
class="org.springframework.data.redis.serializer.StringRedisSerializer" />
<bean id="jackson2JsonRedisSerializer"
class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer" />
<bean id="jdkSerializationRedisSerializer"
class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" /> <!-- 配置缓存 -->
<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
<constructor-arg ref="jdkredisTemplate" />
</bean> <bean id="topicContainer" class="org.springframework.data.redis.listener.RedisMessageListenerContainer" destroy-method="destroy">
<property name="connectionFactory" ref="redisConnectionFactory"/>
<property name="messageListeners">
<map>
<entry key-ref="sub">
<bean class="org.springframework.data.redis.listener.ChannelTopic">
<constructor-arg value="dddchannel"/>
</bean>
</entry>
<entry key-ref="sub2">
<bean class="org.springframework.data.redis.listener.ChannelTopic">
<constructor-arg value="dddchannel"/>
</bean>
</entry>
<entry key-ref="sub3">
<bean class="org.springframework.data.redis.listener.ChannelTopic">
<constructor-arg value="cccchannel"/>
</bean>
</entry>
</map>
</property>
</bean>
Spring RedisTemplate操作-xml配置(1)的更多相关文章
- Spring IOC-基于XML配置的容器
Spring IOC-基于XML配置的容器 我们先分析一下AbstractXmlApplicationContext这个容器的加载过程. AbstractXmlApplicationContext的老 ...
- Spring 入门 web.xml配置详解
Spring 入门 web.xml配置详解 https://www.cnblogs.com/cczz_11/p/4363314.html https://blog.csdn.net/hellolove ...
- spring之pom.xml配置
spring之pom.xml配置 <?xml version="1.0" encoding="UTF-8"?> <project xmlns= ...
- 这一次搞懂Spring Web零xml配置原理以及父子容器关系
前言 在使用Spring和SpringMVC的老版本进行开发时,我们需要配置很多的xml文件,非常的繁琐,总是让用户自行选择配置也是非常不好的.基于约定大于配置的规定,Spring提供了很多注解帮助我 ...
- Spring Ioc容器xml配置
Spring Ioc容器xml配置基本结构: <?xml version="1.0" encoding="UTF-8"?> <beans xm ...
- Spring 使用AOP——xml配置
目录 AOP介绍 Spring进行2种实现AOP的方式 导入jar包 基于schema-based方式实现AOP 创建前置通知 创建后置通知 修改Spring配置文件 基于schema-based方式 ...
- Spring AOP之xml 配置实现
首先这个配置模式估计现在已经不用了,因为我在我们公司的项目里面并没有看到这么配置AOP相关的东西.不过,这个就和学习spring的控制反转(IOC)和依赖注入(DI)一样,刚刚开始的时候,都是从简单的 ...
- 关于Spring中applicationContext.xml配置错误“org/springframework/transaction/interceptor/TransactionInterceptor”的问题解决
问题描述: 在配置spring的applicationContext.xml中的默认事务管理器的时候可能会出现这样的错误: Error occured processing XML 'org/spri ...
- Spring学习之xml配置Bean总结
学习Spring时,我用的是Maven来管理jar包,先看看maven的pom.xml: pom.xml <project xmlns="http://maven.apache.org ...
随机推荐
- docker之搭建私有仓库
一.私有仓库 1.防止网络原因:下载慢,访问不到的情况,需要在内网搭建一个私有仓库. 二.仓库镜像下载 [root@node03 ~]# docker pull registry 三.创建私有仓库容器 ...
- 软件测试--w模型
W模型 优点:开发把随着整个开发周期,需求.和设计同样要测试,更早的介入测试,可以发现初期的缺陷,修复成本低:分阶段工作方便项目整体管理: 缺点:开发和测试依然是线性关系,需求的变更和调整,依然不方便 ...
- 关于go v1.11安装后出现不能正常运行测试程序的问题
本人最近安装go1.11后出现上述问题,没有找到原因,可能之前安装过的旧的版本在windows下环境变量设置出现了问题,修改后仍然无效,后来删除所有安装版本,及go环境变量,重新下载1.10版本进行安 ...
- golang基础--类型与变量
基础知识--类型与变量 基本类型 布尔型:bool 长度: 1字节 取值范围: false, true 注意事项: 不可以使用数字代表,不像 python中可是使用 1和0表示 整型: int/uin ...
- SQL手工注入漏洞测试(Sql Server数据库)
还是先找到注入点,然后order by找出字段数:4 通过SQL语句中and 1=2 union select 1,2,3……,n联合查询,判断显示的是哪些字段,就是原本显示标题和内容时候的查询字段. ...
- 第十五次ScrumMeeting博客
第十五次ScrumMeeting博客 本次会议于12月4日(一)22时整在3公寓725房间召开,持续30分钟. 与会人员:刘畅.辛德泰.张安澜.赵奕.方科栋. 1. 每个人的工作(有Issue的内容和 ...
- 2-Nineteenth Scrum Meeting-20151219
任务安排 成员 今日完成 明日任务 闫昊 写完学习进度记录的数据库操作 请假(数据库) 唐彬 和服务器老师交流讨论区后台接口 请假(数据库) 史烨轩 尝试使用downloadmanager对noti ...
- one team
Double H Team 1.队员 王熙航211606379(队长) 李冠锐211606364 曾磊鑫211606350 戴俊涵211606359 聂寒冰211606324 杨艺勇211606342 ...
- Delphi实现DBGrid全选和反选功能
Delphi实现Dbgrid全选和反选.清除全选的功能,不管是在Delphi下,还是在WEB开发中,这种功能都是很实用的,是进行数据批量操作的基础.本模块就是实现了为Delphi的DBGrid数据列表 ...
- Hbase远程连接:Can't get the locations
当Java API远程连接出错:Can't get the locations 原先填入的是IP地址,后来改为HOSTS文件中配置的主机名问题解决,如下红色字体部分: conf.set("h ...