Lettuce 6.0.1.RELEASE 已弃用 .withPassword
Lettuce 6.0.1.RELEASE deprecated .withPassword
在早期版本 5.1.6.RELEASE 中,withPassword 可以完美运行。
最新版本如何显示警告 withPassword is deprecated.It takes Array[Char] or charSequence .
@transient lazy val redisClient = RedisClient.create(
RedisURI.builder()
.withHost(redisHost)
.withPort(redisPort)
.withPassword(redisAuth)
.withSsl(true)
.build()
根据文档,您不应使用将字符串作为参数的 withPassword
方法,而应使用 CharSequence
或 Array[Char]
- @deprecated since 6.0. Use {@link #withPassword(CharSequence)} or {@link #withPassword(char[])} avoid String caching.
另见 api docs or the plain comments at the source code。
因此,如果只需将您的代码更改为
@transient lazy val redisClient = RedisClient.create(
RedisURI.builder()
.withHost(redisHost)
.withPort(redisPort)
.withPassword(redisAuth.toCharArray)
.withSsl(true)
.build()
你至少会避免警告(但解决了引入该弃用的原因)。也许这个问题+答案值得一读:Why is char[] preferred over String for passwords?.
在早期版本 5.1.6.RELEASE 中,withPassword 可以完美运行。 最新版本如何显示警告 withPassword is deprecated.It takes Array[Char] or charSequence .
@transient lazy val redisClient = RedisClient.create(
RedisURI.builder()
.withHost(redisHost)
.withPort(redisPort)
.withPassword(redisAuth)
.withSsl(true)
.build()
根据文档,您不应使用将字符串作为参数的 withPassword
方法,而应使用 CharSequence
或 Array[Char]
- @deprecated since 6.0. Use {@link #withPassword(CharSequence)} or {@link #withPassword(char[])} avoid String caching.
另见 api docs or the plain comments at the source code。
因此,如果只需将您的代码更改为
@transient lazy val redisClient = RedisClient.create(
RedisURI.builder()
.withHost(redisHost)
.withPort(redisPort)
.withPassword(redisAuth.toCharArray)
.withSsl(true)
.build()
你至少会避免警告(但解决了引入该弃用的原因)。也许这个问题+答案值得一读:Why is char[] preferred over String for passwords?.