spring boot 连接redis报错 org.springframework.data.redis.RedisConnectionFailureException
检查配置
application.properties 配置
(spring boot 低版本 本人1.5.11 版本配置)
spring.redis.host=192.168.59.131
spring.redis.port=6379
#spring.redis.password=root #根据需要
# Redis数据库索引(默认为0)
spring.redis.database=0
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=0
(spring boot 高版本配置)
spring.redis.jedis.pool.max-active=8 或者 spring.redis.lettuce.pool.max-active=8
引自: https://blog.csdn.net/qq_33326449/article/details/80457571
# REDIS (RedisProperties)
# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器地址
spring.redis.host=localhost
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=0
# 连接超时时间(毫秒)
注意:关闭redis的保护模式
注释掉绑定的默认ip
检查虚拟机防火墙是否关闭, 本人CentOS 7
表示防火墙开启, 可以选择关闭防火墙或者添加开启端口
开启端口
关闭防火墙
然后就可以享受redis了, 困扰了好久的问题终于解决