使用Jedis連接redis出現(xiàn)Cannot get Jedis connection; Could not get a resource from the pool錯誤

具體報(bào)錯信息如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

出現(xiàn)錯誤的原因可能有以下幾點(diǎn):

  1. 查看Jedis配置redis的信息是否有誤,主要是ip,端口和密碼是否寫錯。
  2. 查看服務(wù)器防火墻是否關(guān)閉,查看指令:systemctl status firewall,如果出現(xiàn)
    Active:active(running)則表示防火墻是處于開啟狀態(tài)的,需要關(guān)閉。 關(guān)閉指令:systemctl stop firewall。關(guān)閉后是Active: inactive (dead)。
  3. 修改redis配置文件redis.conf。找到bind 127.0.0.1,把它進(jìn)行注釋掉;找到protected-mode yes 把它改成no。
  4. 如果是使用spring-session需要依賴redis2.8.0以上版本,并且需要開啟:notify-keyspace-events gxE;同樣在redis.conf中修改。

上述若修改了redis.conf文件,則必須要重啟redis服務(wù)器。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容