Jedis 使用問題

Could not get a resource from the pool 發生啓動獲取不到鏈接池 redis

本人環境 redis設置密碼,jdis使用JedisPool,設置testOnBorrow =true spa

使用JedisPool, testOnBorrow 鏈接檢查設置爲true時,redis.clients.jedis.JedisFactory#validateObject執行,jedis對象並無賦值密碼,ping須要密碼的redis服務端則鏈接不上! return e.getHost().equals(connectionHost) && e.getPort() == connectionPort && jedis.isConnected() && jedis.ping().equals("PONG");

解決方案: code

A:重寫JedisFactory使其擁有密碼 對象

B:使用ShardJedisPool get

相關文章
相關標籤/搜索