单机模式转化为集群模式错误,需要修改配置,我是直接修改的xml配置文件
<?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:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- spring缓存配置 modify by zhaoyunhua 20170302 -->
<!-- spring缓存机制 -->
<cache:annotation-driven />
<!-- 使用redis缓存 -->
<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager" c:_0-ref="redisTemplate"/>
<!-- redis 相关配置 -->
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="1" />
<property name="maxTotal" value="5" />
<property name="blockWhenExhausted" value="true" />
<property name="maxWaitMillis" value="30000" />
<property name="testOnBorrow" value="true" />
</bean>
<bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" >
<constructor-arg index="0">
<!-- RedisClusterConfiguration, -->
<bean class="org.springframework.data.redis.connection.RedisClusterConfiguration">
<constructor-arg>
<list>
<value>XXX.XXX.XXX.111:6379</value>
<value>XXX.XXX.XXX.112:6379</value>
<value>XXX.XXX.XXX.113:6379</value>
</list>
</constructor-arg>
<property name="maxRedirects" value="5" />
</bean>
</constructor-arg>
<constructor-arg index="1">
<bean class="redis.clients.jedis.JedisPoolConfig">
<property name="maxTotal" value="100"/>
<property name="maxIdle" value="300"/>
<property name="minIdle" value="1"/>
<property name="maxWaitMillis" value="30000"/>
</bean>
</constructor-arg>
</bean>
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
</beans>