Springboot连接Redis超时问题解决
一、问题出现
在使用Springcloud整合Redis作为缓存时,一段时间不去操作,再次刷新会出现连接超时的问题,具体如下:
io.lettuce.core.RedisCommandTimeoutException: Command timed out after 5 second(s)
二、原因
springboot 2.x 默认采用了lettuce作为连接池,但是lettuce是不会进行“心跳”操作的,也就是说,它不会保持连接,导致了连接超时。
三、解决
我们可以将连接池修改为jedis,jedis是会有“心跳”的。
在pom.xml排除lettuce,并修改为jedis
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId><exclusions><exclusion><groupId>redis.clients</groupId><artifactId>jedis</artifactId></exclusion><exclusion><artifactId>lettuce-core</artifactId><groupId>io.lettuce</groupId></exclusion></exclusions>
</dependency>
<dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId>
</dependency>
<dependency><groupId>org.apache.commons</groupId><artifactId>commons-pool2</artifactId>
</dependency>
基础设置:
spring.redis.host=地址
spring.redis.port=6379
spring.redis.password=
spring.redis.database= 0
spring.redis.timeout=5000spring.redis.jedis.pool.max-active=8
spring.redis.jedis.pool.max-wait=2000
#最大阻塞等待时间(负数表示没限制)
spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.min-idle=0
spring.redis.jedis.pool.time-between-eviction-runs=1000
Springboot连接Redis超时问题解决相关推荐
- springboot连接redis错误 io.lettuce.core.RedisCommandTimeoutException:
springboot连接redis报错 超时连接不上 可以从以下方面排查 1查看自己的配置文件信息,把超时时间不要设置0毫秒 设置5000毫秒 2redis服务长时间不连接就会休眠,也会连接不上 重 ...
- Springboot连接redis配置
Springboot连接redis配置 application.properties #Redis服务器地址 spring.redis.host=192.168.233.128 #Redis服务器连接 ...
- 使用RedisDesktopManager客户端无法连接Redis服务器问题解决办法
使用RedisDesktopManager客户端无法连接Redis服务器问题解决办法 参考文章: (1)使用RedisDesktopManager客户端无法连接Redis服务器问题解决办法 (2)ht ...
- SpringBoot连接Redis服务出现DENIED Redis is running in protected mode because protected mode is enabled
问题描述:SpringBoot连接Redis服务出现DENIED Redis is running in protected mode because protected mode is enable ...
- springboot连接redis并动态切换database(db0到db15)
redis redis db0到db15 springboot连接redis 添加配置文件application.properties 测试是否连接成功 redis动态切换database redis ...
- 反恐精英链接服务器中断,枪神传说连接服务器超时问题解决方法 频繁掉线怎么办...
枪神传说连接服务器超时问题解决方法,枪神传说频繁掉线怎么办 枪神传说有的小伙伴会出现频繁掉线的问题,一般比较多的原因是在于当前网络连接不稳定.网络较差引起的,下面一起来看看具体的处理方法吧! 1.检查 ...
- SpringBoot连接redis
1 docker安装redis(6.2.2) 1.1 下载redis镜像 sudo docker pull redis:6.2.2 1.2 设置配置文件 手动创建redis.conf,并添加如下配置参 ...
- springboot连接redis集群
开启redis服务和客户端 查看下当前redis的进程 [root@localhost ~]# ps -ef | grep redis 启动redis服务 [root@localhost ~]# cd ...
- SpringBoot连接Redis服务出现Command timed out
问题描述:SpringBoot整合Redis,连接Redis服务时出现Command timed out 解决方法: 查看配置文件是否是设置的连接超时时间过小,一般将其设置为5000毫秒
- org.springframework.data.redis.RedisSystemException: Error in execution; nes遇到springboot连接Redis报错
org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lett ...
最新文章
- keepalived打造mysql主主高可用
- 干货:嵌入式C语言源代码优化方案(非编译器优化)
- Android之下拉刷新的ListView
- mac+php版本切换+cli,Mac环境下php版本切换
- ScrollView中嵌套recycleView 出现的不显示,显示不全,终极解决方案
- java自定义窗口_Java-创建一个自定义窗口,扁平化界面
- RabbitMQ WEB管理端
- 基础集合论 第一章 6 并集
- Win7 vs2010+Silverlight4开发安装顺序
- 系统电脑频繁假死(突然屏幕卡死,任何操作无法执行)
- Qt 加载翻译文件基本方法
- ios 简单实现半圆形仪表盘 (进度条)
- 基于人工智能的盲人阅读器
- 测开基础串讲-Java基础-测开常用API之Random类
- Python网络编程之初识
- 公历转农历linux C程序
- Spring MVC学习笔记
- vins-fusion代码解读[五] imu在vins里的理解
- CSS库 Tailwind
- 爱普生L355打印机进纸故障排除