连接redis报错:org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis
·
spring连接虚拟机redis数据库报如下错误:
org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis
原因分析:
- 配置文件中的虚拟机地址错误
- 虚拟机防火墙未关闭
虚拟机地址配置
spring:
application:
name: redis-demo
autoconfigure:
exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
data:
redis:
host: 192.168.144.128
port: 6379
password: 123456
lettuce:
pool:
max-active: 8
max-idle: 8
min-idle: 0
max-wait: 100
关闭虚拟机防火墙
输入以下代码查看防火墙状态
systemctl status firewalld

此时防火墙处于开启状态,以下代码可关闭防火墙。
systemctl stop firewalld

关闭后spring即可连接redis数据库。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)