1.maven相关pom.xml

  1. <dependencies>
  2. <!--spring redis-->
  3. <dependency>
  4. <groupId>org.springframework.data</groupId>
  5. <artifactId>spring-data-redis</artifactId>
  6. <version>1.6.0.RELEASE</version>
  7. </dependency>
  8. <!--client 配置-->
  9. <dependency>
  10. <groupId>redis.clients</groupId>
  11. <artifactId>jedis</artifactId>
  12. <version>2.7.3</version>
  13. </dependency>
  14. </dependencies>

2.application_context.xml相关配置

  1. <bean id="jedisConfig" class="redis.clients.jedis.JedisPoolConfig">
  2. <property name="maxTotal" value="300"/>
  3. <property name="maxIdle" value="100"/>
  4. <property name="maxWaitMillis" value="10000"/>
  5. <property name="testOnBorrow" value="true"/>
  6. </bean>
  7. <bean id="jedisConnFactory"
  8. class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
  9. p:usePool="true" p:hostName="${host}" p:password="${password}" c:poolConfig-ref="jedisConfig"/>
  10. <!-- redis template definition -->
  11. <bean id="redisTemplate"
  12. class="org.springframework.data.redis.core.RedisTemplate"
  13. p:connectionFactory-ref="jedisConnFactory">
  14. <property name="keySerializer">
  15. <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
  16. </property>
  17. <property name="valueSerializer">
  18. <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
  19. </property>
  20. <property name="hashKeySerializer">
  21. <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
  22. </property>
  23. <property name="hashValueSerializer">
  24. <bean class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
  25. </property>
  26. </bean>

3.相关调用

  1. @Service("sessionService")
  2. public class SessionService {
  3. @Autowired
  4. private RedisTemplate<String, Map<String, Object>> redisTemplate;
  5. //todo redisTemplate 相关使用
  6. }

spring 配置 redis的更多相关文章

  1. Spring配置redis及使用

    一.redis简介 Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库 Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用. ...

  2. spring配置redis注解缓存

    前几天在spring整合Redis的时候使用了手动的方式,也就是可以手动的向redis添加缓存与清除缓存,参考:http://www.cnblogs.com/qlqwjy/p/8562703.html ...

  3. spring配置redis(xml+java方式)(最底层)

    条件:引用好架包 <dependency> <groupId>org.springframework.data</groupId> <artifactId&g ...

  4. spring配置redis

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

  5. spring mvc Spring Data Redis RedisTemplate [转]

    http://maven.springframework.org/release/org/springframework/data/spring-data-redis/(spring-data包下载) ...

  6. Spring Data Redis简介以及项目Demo,RedisTemplate和 Serializer详解

    一.概念简介: Redis: Redis是一款开源的Key-Value数据库,运行在内存中,由ANSI C编写,详细的信息在Redis官网上面有,因为我自己通过google等各种渠道去学习Redis, ...

  7. spring使用redis做缓存

    缓存 什么是缓存? 在高并发下,为了提高访问的性能,需要将数据库中 一些经常展现和不会频繁变更的数据,存放在存取速率更快的内存中.这样可以 降低数据的获取时间,带来更好的体验 减轻数据库的压力 缓存适 ...

  8. Spring下redis的配置

    这个项目用到redis,所以学了一下怎样在Spring框架下配置redis. 1.首先是在web.xml中添加Spring的配置文件. <web-app version="3.0&qu ...

  9. spring集成redis——主从配置以及哨兵监控

    Redis主从模式配置: Redis的主从模式配置是非常简单的,首先我们需要有2个可运行的redis环境: master node : 192.168.56.101 8887 slave node: ...

随机推荐

  1. python os 命令,及判断文件夹是否存在

    使用前 import os导入模块   os模块: os.sep     可以取代操作系统特定的路径分割符 os.linesep  字符串给出当前平台使用的行终止符.例如,Windows使用'\r\n ...

  2. 此实现不是 Windows 平台 FIPS 验证的加密算法的一部分

    在实用VS编程的时候大家经常会遇到一个问题: 下面小编来为大家提供一个简单的解决方案: 1.在Windows中打开功能里输入regedit,回车打开注册表编辑器: 2.转到路径HKEY_LOCAL_M ...

  3. c++的构造函数

    我刚学的知识:c++的构造函数.在在此之前一直都处于迷惑之中,现在怕忘.所以赶紧把他写下来,用来以后复习,可能有错误的地方,请大牛们指出来.c++知识相对与c来说更加抽象,但真明白了,也就那一回事.这 ...

  4. 3-PHP全部编码UTF-8

    0-html <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ...

  5. 00Linux学习及角色定义

    一.嵌入式Linux学习顺序 二.Linux架构 三.Linux工程师角色划分 四. 嵌入式应用工程师工作内容与所需知识点 从图 1可以知道, 嵌入式应用工程师主要从事与产品相关的嵌入式 Linux ...

  6. aspcms,2.x以上版本,保护栏目不可删除处理方法

    aspcms,2.x以上版本,保护栏目不可删除处理方法.首先找到\admin\_content\_Sort\AspCms_SortFun.asp这个文件.然后将if  isnul(id) then a ...

  7. 夺命雷公狗-----React_native---4---初始化项目

    我们首先在android目录下创建一个apps的文件夹: 然后我们在apps目录下,按住shift键加鼠标右键选择--在此打开命令窗口输入命令初始化项目 然后就是等了................. ...

  8. Silverlight动态生成控件实例

    刚学习Silverlight,做了一个动态创建控件的实例 实现结果:根据已有的控件类名称,得到控件的实例化对象 实现思路1:就是定义一个模板文件,将类名做为参数,在silverlight中使用Srea ...

  9. python之三层菜单递归

    首先非常感谢11期的学长薜保库提供了一种非常实用函数递归方法,让实现三层菜单如此简单,不过对所遍历的嵌套字典或列表格式有所要求.有特定的环境下非常实用. 主要针对中国的各省市区进行展示,采用了百度的j ...

  10. Qt 工程 pro文件

    工作中,感觉pro文件的有些内容真不太懂,现系统性的学习一下.于此备录,分享共勉. 为了更好的理解,先创建一个简单的工程作为实践. [1]创建一个pro文件 1.1 新建proDemo工程.步骤如下: ...