背景:redis.conf
設置密碼後,代碼裏面應該也要設置密碼
問題:redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
操作:趕緊去看JedisPool
,發現構造函數裏面剛好有個password
字段,毫不猶豫把密碼填進去。啓動,測試發現就報了上面的問題。
JedisPool
查了許久,終於在stackoverflow
上找到了(點擊跳轉
)
Try setting your Redis password after using pool. I was having some problem with AUTH as well and then saw someone having similar problem with Lettuce by setting redis password before using pool. Change the order, once you set your factory to use pool, then set the password. The solution worked fine for me.
解決:jedisConnectionFactory.setPassword(password)