org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 127.0.0.1:6379
找一下原因:
如果是远程访问redis:
1.redis.conf文件有一项配置默认是bind 127.0.0.1,也就是默认只支持本机访问Redis,你把这一项注释掉。
2.找到protected-mode yes 把它改成no。
3.查看虚拟机防火墙是否关闭
4.改完后要重启redis
如果是本机访问:
一般是配置文件的错误
1.查看配置文件 redis的ip地址和端口是否正确 本地一般配置是 127.0.0.1:6379
redis默认的端口是6379 如果改过就用改过的
2.spring.redis.timeout=10000 设置一下连接超时的时间
3.配置文件的连接密码,是否正确,如果没有设置密码,不必写上
4.查看本地的redi是否是启动状态
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=1234 #没有密码 可以不写
spring.redis.timeout=10000