<?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:context="http://www.springframework.org/schema/context"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

 	<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"  
       p:host-name="${redis.host1}" p:port="${redis.port1}" p:password="${redis.password1}" p:pool-config-ref="poolConfig"/>  

	<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
		<property name="minIdle" value="${redis.minIdle}" />
		<property name="maxIdle" value="${redis.maxIdle}" />
		<property name="maxTotal" value="${redis.maxActive}" />
		<property name="maxWaitMillis" value="${redis.maxWait}" />
		<property name="testOnBorrow" value="${redis.testOnBorrow}" />
	</bean>


	<!-- Spring Data Redis 设置 -->
	<!-- redis 序列化策略 ，通常情况下key值采用String序列化策略， -->
	<!-- 如果不指定序列化策略，StringRedisTemplate的key和value都将采用String序列化策略； -->
	<bean id="stringRedisSerializer"
		class="org.springframework.data.redis.serializer.StringRedisSerializer" />
	<bean id="jdkRedisSerializer"
		class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />

	<!-- redis template definition p表示对该bean里面的属性进行注入，格式为p:属性名=注入的对象 效果与在bean里面使用<property>标签一样 -->
	<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
		p:connectionFactory-ref="redisConnectionFactory" p:keySerializer-ref="stringRedisSerializer"
		p:hashKeySerializer-ref="stringRedisSerializer" p:valueSerializer-ref="jdkRedisSerializer"
		p:hashValueSerializer-ref="jdkRedisSerializer" />
</beans>  