配置多个redis客户端
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="masterJedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="10.0.0.2"/>
<property name="port" value="6379"/>
<property name="password" value="**************"/>
<property name="usePool" value="true"/>
</bean>
<bean id="slaveJedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="10.0.0.3"/>
<property name="port" value="6379"/>
<property name="password" value="*************"/>
<property name="usePool" value="true"/>
</bean>
<bean id="masterRedisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="masterJedisConnectionFactory"/>
</bean>
<bean id="slaveRedisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="slaveJedisConnectionFactory"/>
</bean>
</beans>