First, Spring-data-redis
1.jar Pack
<!--redis--><dependency> <groupId>redis.clients</groupId> <artifactId> jedis</artifactid> <version>2.1. 0</version></dependency><dependency> <groupid>org.springframework.data</ groupid> <artifactId>spring-data-redis</artifactId> <version>1.0. 2. Release</version></dependency>
2.xml file
<bean id="Poolconfig" class="Redis.clients.jedis.JedisPoolConfig"> <property name="Maxidle"Value="${redis.maxidle}"/> <property name="maxactive"Value="${redis.maxactive}"/> <property name="maxwait"Value="${redis.maxwait}"/> <property name="Testonborrow"Value="${redis.testonborrow}"/> </bean> <bean id="ConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"P:hostname="${redis.host}"p:port="${redis.port}"p:password="${redis.pass}"p:poolconfig-ref="Poolconfig"/> <bean id="redistemplate" class="org.springframework.data.redis.core.StringRedisTemplate"> <property name="ConnectionFactory" ref="ConnectionFactory"/> </bean>
3. Injection use
@Resource protected Redistemplate<serializable, serializable> redistemplate;
Spring Integrated Redis