异常描述
新建了一个项目,我自己的服务器安装了一个redis,安装的时候,基本上都是默认参数,然后SpringBoot配置如下:
1 | spring: |
在项目启动的时候,报错:
1 | Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisTemplate' defined in class path resource [com/qianxunclub/starter/redis/autoconfigure/RedisConfig.class]: Unsatisfied dependency expressed through method 'redisTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration$RedisConnectionConfiguration.class]: Invocation of init method failed; nested exception is redis.clients.jedis.exceptions.JedisDataException: ERR This instance has cluster support disabled |
异常分析
从报错误的信息ERR This instance has cluster support disabled
很明显看得出来,是没有启动redis集群功能,可是我项目配置的集群的配置方式,要么修改代码为单机配置,要么修改redis为集群方式。
解决办法
1、可以修改配置为单机redis配置:
1 | spring: |
2、在安装redis的目录找到redis配置文件redis.conf
,里面会找到配置:
1 | # cluster-enabled yes |
把注释去掉就可以了
1 | cluster-enabled yes |