介绍
在使用redis做集群的时候,启动SpringBoot遇到的问题。
2020-12-21 16:22:03.294 ERROR 2192 --- [isson-netty-2-8] o.r.cluster.ClusterConnectionManager : Can't connect to master: redis://127.0.0.1:7003 with slot ranges: [[5461-10922]]
2020-12-21 16:22:03.294 ERROR 2192 --- [isson-netty-2-7] o.r.cluster.ClusterConnectionManager : Can't connect to master: redis://127.0.0.1:7002 with slot ranges: [[10923-16383]]
2020-12-21 16:22:03.294 ERROR 2192 --- [isson-netty-2-9] o.r.cluster.ClusterConnectionManager : Can't connect to master: redis://127.0.0.1:7005 with slot ranges: [[0-5460]]
2020-12-21 16:22:05.391 WARN 2192 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redissonController' defined in file [D:\Space\Projects\JavaWeb\Java-Practice\spring-redisson\target\classes\com\example\demo\config\RedissonController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisson' defined in class path resource [org/redisson/spring/starter/RedissonAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'redisson' threw exception; nested exception is org.redisson.client.RedisConnectionException: Can't connect to servers!
2020-12-21 16:22:05.401 INFO 2192 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-12-21 16:22:05.443 INFO 2192 --- [ main] ConditionEvaluationReportLoggingListener :
解决办法
检查redis.conf是否配置了bind 127.0.0.1,如果有注释掉,另外把protected-mode设置为no