开发中 springboot连接redis
springboot:redis报错io.lettuce.core.RedisCommandExecutionException: ERR Client sent AUTH, but no passw
解决办法
一、报错原因:下载安装的redis默认是没有密码的。
所以在项目中配置文件中,连接redis,配置了密码。就会报错。
二、解决:给redis设置密码
1、命令窗口,进入到redis所在的目录下
2、然后输入 redis-cli 回车
3、输入 config set requirepass 789789 回车
789789 就是密码
三、application.yml的redis配置中的spring.redis.timeout中连接超时时间(毫秒)中时间设置不能为0
四、找到redis的配置文件 redis.conf
vim redis.conf
修改 protected-mode yes 改为:protected-mode no
注释掉 #bin 127.0.0.1
五、yml文件中配置参数
REDIS (RedisProperties)
Redis数据库索引(默认为0)
spring.redis.database=0
Redis服务器地址
spring.redis.host=192.168.30.103
Redis服务器连接端口
spring.redis.port=6379
连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=8
连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1
连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=8
连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=0
连接超时时间(毫秒)
spring.redis.timeout=5000