【工作笔记】Springboot集成Redis添加密码连接NOAUTH Authentication required

一个很简单的问题,使用Springboot集成Redis,并且添加Auth授权,正常配置我认为是这样的:

spring:
  redis:
    database: 0
    url: redis://127.0.0.1:6379
    password: 123456password
    ssl: false
    timeout: 1000
    jedis:
      pool:
        max-active: 1000
        max-wait: 100s
        max-idle: 1000
        min-idle: 1000

配置好以后,开启压测,收到铺天盖地的错误“NOAUTH Authentication required”:

Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
 at redis.clients.jedis.Protocol.processError(Protocol.java:127)
 at redis.clients.jedis.Protocol.process(Protocol.java:161)
 at redis.clients.jedis.Protocol.read(Protocol.java:215)
 at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:340)
 at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:239)
 at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:196)
 at redis.main(redis.java:9)

再次确认我的password没有问题,单步调试发现问题:springboot在获取密码时,没有直接从password里拿,而是直接从uri里拿,将配置改成:

spring:
  redis:
    database: 0
    url: redis://[email protected]:6379
    ssl: false
    timeout: 1000
    jedis:
      pool:
        max-active: 1000
        max-wait: 100s
        max-idle: 1000
        min-idle: 1000

正常运行,问题解决。

我无话可说。。

你可能感兴趣的:(java,java,后端)