Spring4 整合 Redis

pom构建:

[html]  view plain   copy
  print ?
  1. <modelVersion>4.0.0</modelVersion>  
  2. <groupId>com.x.redis</groupId>  
  3. <artifactId>springredis</artifactId>  
  4. <version>0.0.1-SNAPSHOT</version>  
  5.   
  6. <dependencies>  
  7.     <dependency>  
  8.         <groupId>org.springframework.data</groupId>  
  9.         <artifactId>spring-data-redis</artifactId>  
  10.         <version>1.0.2.RELEASE</version>  
  11.     </dependency>  
  12.     <dependency>  
  13.         <groupId>org.springframework</groupId>  
  14.         <artifactId>spring-test</artifactId>  
  15.         <version>3.1.2.RELEASE</version>  
  16.         <scope>test</scope>  
  17.     </dependency>  
  18.       
  19.     <dependency>  
  20.         <groupId>redis.clients</groupId>  
  21.         <artifactId>jedis</artifactId>  
  22.         <version>2.1.0</version>  
  23.     </dependency>  
  24.       
  25.      <dependency>  
  26.         <groupId>junit</groupId>  
  27.         <artifactId>junit</artifactId>  
  28.         <version>4.8.2</version>  
  29.         <scope>test</scope>  
  30.     </dependency>  
  31. </dependencies>  

spring配置文件(applicationContext.xml):

[html]  view plain   copy
  print ?
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"  
  4.     xmlns:context="http://www.springframework.org/schema/context"  
  5.     xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"  
  6.     xmlns:aop="http://www.springframework.org/schema/aop"  
  7.     xsi:schemaLocation="  
  8.             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  
  9.             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">  
  10.   
  11.     <context:property-placeholder location="classpath:redis.properties" />  
  12.   
  13.     <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">  
  14.         <property name="maxIdle" value="${redis.maxIdle}" />  
  15.         <property name="maxActive" value="${redis.maxActive}" />  
  16.         <property name="maxWait" value="${redis.maxWait}" />  
  17.         <property name="testOnBorrow" value="${redis.testOnBorrow}" />  
  18.     </bean>  
  19.       
  20.     <bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"  
  21.         p:host-name="${redis.host}" p:port="${redis.port}" p:password="${redis.pass}"  p:pool-config-ref="poolConfig"/>  
  22.       
  23.     <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">  
  24.         <
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值