Springboot配置Redis报:io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.

起因:

Redis服务设置密码后,同样的在springboot配置文件中配置password,使用RedisTemplate时,控制台打印如下:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.] with root cause
io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
也就是没有权限

版本:

sringboot 2.2.2.RELEASE

  <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
        <version>2.2.2.RELEASE</version>
      </dependency>

分析:

可视化工具连接使用密码,连接成功。所有就基本确定是springboot没有读取到配置的password

解决:

redis 还有个url 配置,使用url配置连接
spring.redis.url

在这里插入代码片spring:
  application:
    name: application-name
  redis:
    host: ip
    port: 6379
    #password: password
    database: 0
    url: redis://password@ip:6379
    lettuce:
      pool:
        #最大连接数
        max-active: 32
        #最大阻塞等待时间
        max-wait: 300ms
        #最大空闲连接
        max-idle: 16
        min-idle: 8
    #连接超时时间
    timeout: 1000

-Ending-

  • 7
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值