springboot 2.0.0+连接redis失败
2019-01-13 23:24
253 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_28949651/article/details/86443220
1.首先在redis.conf中注释掉bind 127.0.0.1这一行,其意思是只允许本地访问连接,其他Ip都将被拒绝.
vim /etc/redis.conf
2.如果第一步操作过后,依然拒绝连接,可能为redis部署机器的防火墙没有关闭或者网络不通,进行如下操作:
关闭防火墙:
(centos7)systemctl stop firewalld.service (centos6)service iptables stop
3.本地测试远程端口
telnet ip:port ip:远程服务器ip port:redis默认端口6379
如果还是显示链接拒绝,如果你用的是阿里云,请检查安全组
0.0.0.0/0 代表允许或拒绝所有IP的访问,设置时请务必谨慎
4.如果springboot版本2.0.3以上
可能是springboot配置文件key有问题,springboot 2.0.3默认是使用lettuce连接redis,配置文件不能按照jedis的方法连接
spring.redis.host=localhost spring.redis.port=6379 #根据需要 #spring.redis.password=123456 # 连接超时时间(毫秒) spring.redis.timeout=10000 # Redis默认情况下有16个分片,这里配置具体使用的分片,默认是0 spring.redis.database=0 # 连接池最大连接数(使用负值表示没有限制) 默认 8 spring.redis.lettuce.pool.max-active=8 # 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1 spring.redis.lettuce.pool.max-wait=-1 # 连接池中的最大空闲连接 默认 8 spring.redis.lettuce.pool.max-idle=8 # 连接池中的最小空闲连接 默认 0 spring.redis.lettuce.pool.min-idle=0
并且还要引入commons-pool2包,这样springboot2.0.3连接redis就成功了
相关文章推荐
- Springboot整合redis的连接失败问题
- docker安装redis连接redis可视化工具Redis Desktop Manager+springboot项目使用Cache缓存+springboot项目整合 Redis 实现缓存
- springboot 连接redis报错 nested exception is redis.clients.jedis.exceptions.JedisConnectionException
- Spring Session java连接redis 失败解决方案
- spring boot 连接 redis
- SpringBoot---客户端连接虚拟机的Redis
- 详解springboot配置多个redis连接
- springboot连接redis单机版
- Spring Session java连接redis 失败解决方案
- IntelliJ IDEA Springboot 连接数据库失败(错误提示POST url 500)
- 在springboot中远程连接redis遇到的问题
- spring boot下JedisCluster方式连接Redis集群的配置
- Spring Boot 连接 redis 集群
- Spring Boot分布式系统实践【扩展1】shiro+redis实现session共享、simplesession反序列化失败的问题定位及反思改进
- docker安装redis连接redis可视化工具Redis Desktop Manager+springboot项目使用Cache缓存+springboot项目整合 Redis 实现缓存
- Springboot2.X集成redis集群(Lettuce)连接的方法
- Spring boot集成redis及缓存操作失败的异常处理
- centos7环境下搭建redis及springboot连接集成
- Spring Boot Actuator报出的redis连接不上的问题
- SpringBoot整合redis