起因:

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-

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐