【发布时间】:2016-05-30 00:58:24
【问题描述】:
我使用 spring-data-redis 版本 1.7.0.M1 和 jedis 版本 2.8.0 这是我的配置
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="redisConnectionFactory"></property>
<property name="keySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="hashKeySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="valueSerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="hashValueSerializer">
<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>
</property>
</bean>
并使用【redisTemplate.opsForValue().get("foo")】进行测试
抛出异常
org.springframework.dao.InvalidDataAccessApiUsageException: MOVED 12182 192.168.1.223:7002; nested exception is redis.clients.jedis.exceptions.JedisMovedDataException: MOVED 12182 192.168.1.223:7002
使用spring-data-redis 1.7.0.M1时如何配置redis-cluster?
【问题讨论】:
-
集群需要在
RedisConnectionFactory上配置。能否请您为其添加配置。此外,在 github 上的 spring-data-examples 存储库以及 reference documentation 中还有一个 Redis Cluster 示例项目。
标签: redis spring-data-redis redis-cluster