redis 安裝在服務器上,本地配置好後使用JedisUtils進行緩存處理時,會報鏈接不上redis服務器錯誤,具體錯誤信息以下:redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
Caused by: redis.clients.jedis.exceptions.JedisConnectionException java.net.ConnectException: Connection refused: connectjava
緣由:redis得bind若是是 127.0.0.1 或localhost的 話,只能本機 訪問,若是是 0.0.0.0的話,表明任何機器均可以訪問。mysql
解決辦法:找到redis安裝包下redis.window.conf 文件在bind127.0.0.1下面添加一行 bind 0.0.0.0redis
附:redis安裝 cd到安裝目錄下執行下邊dos命令sql
redis-server.exe redis.windows.conf數據庫
測試使用:windows
dos命令:redis-cli.exe -h 192.168.10.61 -p 6379 緩存
flushall ——> 清空整個 Redis 服務器的數據(刪除全部數據庫的全部 key )服務器
flushdb ——> 清空當前數據庫中的全部 key測試
2.查詢redis全部key.net
Set set = JedisUtils.getResource().keys("*"); System.out.print(set); for (String str : (Set<String>)set) { System.out.println(str); }