一、问题出现

在使用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超时问题解决相关推荐

  1. springboot连接redis错误 io.lettuce.core.RedisCommandTimeoutException:

    springboot连接redis报错 超时连接不上  可以从以下方面排查 1查看自己的配置文件信息,把超时时间不要设置0毫秒 设置5000毫秒 2redis服务长时间不连接就会休眠,也会连接不上 重 ...

  2. Springboot连接redis配置

    Springboot连接redis配置 application.properties #Redis服务器地址 spring.redis.host=192.168.233.128 #Redis服务器连接 ...

  3. 使用RedisDesktopManager客户端无法连接Redis服务器问题解决办法

    使用RedisDesktopManager客户端无法连接Redis服务器问题解决办法 参考文章: (1)使用RedisDesktopManager客户端无法连接Redis服务器问题解决办法 (2)ht ...

  4. 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 ...

  5. springboot连接redis并动态切换database(db0到db15)

    redis redis db0到db15 springboot连接redis 添加配置文件application.properties 测试是否连接成功 redis动态切换database redis ...

  6. 反恐精英链接服务器中断,枪神传说连接服务器超时问题解决方法 频繁掉线怎么办...

    枪神传说连接服务器超时问题解决方法,枪神传说频繁掉线怎么办 枪神传说有的小伙伴会出现频繁掉线的问题,一般比较多的原因是在于当前网络连接不稳定.网络较差引起的,下面一起来看看具体的处理方法吧! 1.检查 ...

  7. SpringBoot连接redis

    1 docker安装redis(6.2.2) 1.1 下载redis镜像 sudo docker pull redis:6.2.2 1.2 设置配置文件 手动创建redis.conf,并添加如下配置参 ...

  8. springboot连接redis集群

    开启redis服务和客户端 查看下当前redis的进程 [root@localhost ~]# ps -ef | grep redis 启动redis服务 [root@localhost ~]# cd ...

  9. SpringBoot连接Redis服务出现Command timed out

    问题描述:SpringBoot整合Redis,连接Redis服务时出现Command timed out 解决方法: 查看配置文件是否是设置的连接超时时间过小,一般将其设置为5000毫秒

  10. org.springframework.data.redis.RedisSystemException: Error in execution; nes遇到springboot连接Redis报错

    org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lett ...

最新文章

  1. keepalived打造mysql主主高可用
  2. 干货:嵌入式C语言源代码优化方案(非编译器优化)
  3. Android之下拉刷新的ListView
  4. mac+php版本切换+cli,Mac环境下php版本切换
  5. ScrollView中嵌套recycleView 出现的不显示,显示不全,终极解决方案
  6. java自定义窗口_Java-创建一个自定义窗口,扁平化界面
  7. RabbitMQ WEB管理端
  8. 基础集合论 第一章 6 并集
  9. Win7 vs2010+Silverlight4开发安装顺序
  10. 系统电脑频繁假死(突然屏幕卡死,任何操作无法执行)
  11. Qt 加载翻译文件基本方法
  12. ios 简单实现半圆形仪表盘 (进度条)
  13. 基于人工智能的盲人阅读器
  14. 测开基础串讲-Java基础-测开常用API之Random类
  15. Python网络编程之初识
  16. 公历转农历linux C程序
  17. Spring MVC学习笔记
  18. vins-fusion代码解读[五] imu在vins里的理解
  19. CSS库 Tailwind
  20. 爱普生L355打印机进纸故障排除

热门文章

  1. P1262 间谍网络+Trajan 缩点(有向图)
  2. 沉淀 2017,记录不平凡的一年!
  3. Axure 软件自带的图标元件Icons无法显示的问题解决方法
  4. linux grep -rn如何只过滤第二层的某个文件夹
  5. 淘宝返利微信公众号怎么使用微信返利机器人查淘宝优惠券及淘宝购物返利?
  6. 全国高校经纬度(txt版)
  7. wd移动硬盘不能识别_wd移动硬盘读不出来怎么办
  8. java opts参数_JVM内存JAVA_OPTS参数说明
  9. CALL TRANSACTION使用及传参数和权限检查(authority-check)
  10. 设计参考之不凡的日本LOGO