--Redis入坑--redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool

问题描述

今天在测试连接到本地VM里的Redis时,发现给我报了个这么个错误:
Exception in thread “main” redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool
就很纳闷是啥子情况,明明本地防火墙iptables也配置了相关规则,端口已经开放了,然后连接地址和端口也没错,照道理是进得去的,可是偏偏又报了这个错误。

相关规格参数

名称 版本
本机系统 Windows10 教育版
虚拟机载体 VMWare workstation 15.5 pro
虚拟机系统 Centos7.6
Redis版本 3.2.1
Jedis版本 2.9.0
JDK版本 1.8

问题原因

是我这个版本的Redis默认开启了保护模式,即不允许非本机的ip连接进入客户端,所以我的连接请求会被拒绝。--Redis入坑--redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool

解决方法

在本地Centos7中,首先保证开启了Redis服务端,后再在虚拟机中打开客户端,然后进入成功后输入:config set protected-mode "no"关闭包含模式即可连接成功。
--Redis入坑--redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool

运行结果

--Redis入坑--redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool
--Redis入坑--redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool
--Redis入坑--redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool