使用客户端jedis时报错Could not get a resource from the pool 以及使用Spring Data Redis报错解决方法
一.Jedis
报错
今天在使用jedis时,一直报错
Could not get a resource from the pool
在网上找了好多解决的方法,并且找了半天错误,才发现是我的启动方式有问题。。。(初学者太菜了)
解决方式
原来启动只是使用的后台启动(默认配置)
redis-server &
然后进入客户端,有时候不用输密码都能用(我设置了密码的)
并且在iead中使用时一直连不上redis,配置文件看了又看也没发现问题。
public class JedisConnectionFactory {private static final JedisPool jedisPool;static{//配置连接池JedisPoolConfig poolConfig = new JedisPoolConfig();poolConfig.setMaxTotal(8);poolConfig.setMaxIdle(8);poolConfig.setMinIdle(0);poolConfig.setMaxWaitMillis(-1);//创建连接池对象jedisPool = new JedisPool(poolConfig,"192.168.142.130",6379,1000,"123456");}public static Jedis getJedis(){return jedisPool.getResource();}
}
后来指定配置文件启动才能连接redis(我在redis.conf设置了密码的)
redis-server /opt/redis/redis.conf &
可以成功使用了哇
关闭redis:(xxxxx填写密码)
redis-cli -a xxxxx shutdown
二.Spring Data Redis
报错
Unable to connect to Redis; nested exception is org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.142.130:6379
解决
yml中的配置
spring:redis:host: 192.168.142.130port: 6379password: 123456lettuce:pool:max-active: 8max-idle: 8min-idle: 0max-wait: 100ms
其实这个错误出现的原因和上面一样,都是redis启动方式的问题
指定配置文件启动就能成功连接redis。
启动后,即可正常连接redis啦
202211091935三
使用客户端jedis时报错Could not get a resource from the pool 以及使用Spring Data Redis报错解决方法相关推荐
- Spring Data Jpa 报错org.hibernate.LazyInitializationException: could not initialize proxy
问题描述:使用JPA原生API接口进行与数据库层的交互报错 org.hibernate.LazyInitializationException: could not initialize proxy ...
- linux java连接redis_java 连接linux的redis 报错。但是linux 客户端可以连接redis
480 localhost-startStop-1 ERROR com.hgd.MainSetup redis启动异常 redis.clients.jedis.exceptions.JedisConn ...
- redis报错,Could not get a resource from the pool,Unable to validate object找不到可用的连接池
报错如下: 追踪源码发现第一个错误信息redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource ...
- Redis - Spring Data Redis 操作 Jedis 、Lettuce 、 Redisson
文章目录 官网 Jedis VS Lettuce Jedis Code POM依赖 配置文件 配置类 单元测试 Lettuce Code Redisson Code POM依赖 配置文件 配置类 单元 ...
- Spring Data Redis与Jedis的选择(转)
说明:内容可能有点旧,需要在业务上做权衡. Redis的客户端有两种实现方式,一是可以直接调用Jedis来实现,二是可以使用Spring Data Redis,通过Spring的封装来调用.应该使用哪 ...
- SpringBoot 整合Redis报错:NoClassDefFoundError: redis/clients/util/SafeEncoder
QUESTION:SpringBoot 整合Redis报错:NoClassDefFoundError: redis/clients/util/SafeEncoder? ANSWER: 这种情况是版本不 ...
- 记一次线上redis报错(JedisExhaustedPoolException: Could not get a resource since the pool is exhausted)
错误详情 redis.clients.jedis.exceptions.JedisExhaustedPoolException: Could not get a resource since the ...
- mysql load报错_mysql:执行LOAD DATA LOCAL 报错
mysql:执行LOAD DATA LOCAL 报错. 我使用navicat for mysql 连接 mysql服务器执行local 可以正常执行 . show VARIABLES like '% ...
- 解决Redis报错:MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist
解决Redis报错:MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on ...
最新文章
- HashFlare矿池退出BTC挖矿,Coingeek矿池继续增加BCH算力
- php获得可靠的精准的当前时间 ( 通过授时服务器 )
- 服务器说你注册过多,为什么我的世界服务器说此用户名已被注册我都换了很多用户了都没用 爱问知识人...
- 窗口操作-关闭,最小化
- 阿里云CDN直播架构与双11晚会直播实战
- 为什么谷歌要执行严格的代码编写规范?
- Pycharm解决plotly不显示离线网页的问题
- kiss原则包括什么_KISS原则
- iso 系统降级的处理方法
- MFC之映美精双目相机保存图片
- 联通bss转cbss_携号转网山西联通经业务系统受理的首张携入号码开卡成功
- 普通人无法预约鸿蒙系统,小蝶加人引流软件支持鸿蒙系统吗
- 复化梯形公式matlab程序,复化梯形公式,辛普森公式的matlab程序
- 终于拿到了阿里2023年度九大Java技术文档——面试题+文档+白皮书
- linux作业管理系统pbs,集群上作业提交系统LSF和PBS的使用与简介
- c语言链表拆分,P2 拆分链表
- SpringCloud2020学习笔记13——SpringCloud Stream消息驱动
- C语言学习之认识exit()函数
- 启动 jack server 出现 Could not find or load main class com.android.jack.launcher.ServerLauncher的问题
- Mybatis批量将list数据插入到Oracle数据库