我是靠谱客的博主 震动星月,这篇文章主要介绍Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication,现在分享给大家,希望可以做个参考。
总结出现这种错误的原因有两种可能
一、redis设置了用户密码,但是在代码连接的时候没有数据密码,导致连接错误
Jedis jedis = new Jedis("x.x.x.x",6379);
System.out.println("连接成功");
这个表示利用端口连接,因为如果redis不设置密码这样是可以连接的,如果设置了密码就需要添加密码,如下:
Jedis jedis = new Jedis("x.x.x.x",6379);
System.out.println("连接成功");
jedis.auth("password");
二、调用设置密码的方法有错误,记住redis设置密码的方法是auth()。
auth();//设置密码
这个方法来自于Jedis父类BinaryJedus,源码如下:
public String auth(String password) {
this.checkIsInMultiOrPipeline();
this.client.auth(password);
return this.client.getStatusCodeReply();
}
最后
以上就是震动星月最近收集整理的关于Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication的全部内容,更多相关Exception内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复