jedis-7.1.0.jar 升级至 jedis-7.2.0.jar 就提示:The type JedisPoolConfig is deprecated The type JedisPooled is deprecated
这是因为从 Jedis 7.2.0 开始,一些类被标记为过时(deprecated)了。让我解释一下原因和解决方案:
原因
Jedis 正在重构连接池的设计,从 7.2.0 版本开始:
-
JedisPoolConfig 被标记为过时 -
JedisPooled 被标记为过时 -
使用更通用的
GenericObjectPoolConfig替代
主要变化总结
|
7.1.0 及之前
|
7.2.0 及之后
|
备注
|
|---|---|---|
JedisPoolConfig |
GenericObjectPoolConfig |
来自 commons-pool2
|
JedisPooled |
JedisPool+ try-with-resources |
手动管理资源
|
|
或使用
UnifiedJedis |
新的单连接客户端
|
迁移建议
-
如果你只需要单连接,使用
UnifiedJedis -
如果需要连接池,使用
JedisPool+GenericObjectPoolConfig -
考虑使用 try-with-resources 确保资源正确关闭
浙公网安备 33010602011771号