1. 配置方式
单点和集群配置,参看下文
https://blog.csdn.net/MOTUI/article/details/52903397
2. 遭遇问题
2.1 标签飘红
解决方法 :
把标签中的代码重新粘一次,不行就去掉中文再来一次,再不行就手打
原因:好像是从个别博客复制来的格式有问题
2.2 RedisClusterConfiguration无法调用(红色)
解决方法:
提升pom里的 jedis
、spring-data-redis
的版本
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.7.11.RELEASE</version>
</dependency>
2.3 maxRedirects这个属性注不进去
报错内容:
org.springframework.beans.NotWritablePropertyException: Invalid property ‘maxRedirects’ of bean class [org.springframework.data.redis.connection.RedisClusterConfiguration]: Bean property ‘maxRedirects’ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
解决方法:
提升pom里spring相关包
的版本
<dependency>
<groupId>Spring的系列包</groupId>
<artifactId>Spring的系列包</artifactId>
<version>4.2.5.RELEASE以上</version>
</dependency>