错误描述
在运行黑马点评的时候连接不上redis:
错误信息:Factory method 'redissonClient' threw exception; nested exception is org.redisson.client.RedisConnectionException: Unable to connect to Redis server: /127.0.0.1:6379
检查:
- redis的ip和端口号都修改为本地的ip和端口,配置正确。
- redis本身没有设置密码,所以连接redis的命令语句中密码内容没有修改,因为在使用Another Redis Desktop Manager连接redis的时候,发现密码随便怎么填都能连接
解决方案
注释掉密码
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
//.setPassword("123321");
host: 127.0.0.1
port: 6379
#password:
原因
如果在客户端设置密码,客户端代码中的 password 配置会主动发起认证请求(如 Jedis 的 setPassword() 或 Spring Boot 的 setPassword())。
如果服务器未启用认证,客户端发送的 AUTH 命令会触发错(AuthenticationException),导致连接失败或无法执行命令。
补充
原理不确定,是ds补充,之前有看到博客说如果没有设置密码,就算config.useSingleServer().setAddress(“redis://127.0.0.1:6379”).setPassword(“”);
这里面的password设置为空也没有用,会给密码输入一个空值,因此还是会输入密码。
希望有人看到这篇博客帮我补充。