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 版本开始:
  1. JedisPoolConfig​ 被标记为过时
  2. JedisPooled​ 被标记为过时
  3. 使用更通用的 GenericObjectPoolConfig替代

主要变化总结

7.1.0 及之前
7.2.0 及之后
备注
JedisPoolConfig
GenericObjectPoolConfig
来自 commons-pool2
JedisPooled
JedisPool+ try-with-resources
手动管理资源
或使用 UnifiedJedis
新的单连接客户端

迁移建议

  1. 如果你只需要单连接,使用 UnifiedJedis
  2. 如果需要连接池,使用 JedisPool+ GenericObjectPoolConfig
  3. 考虑使用 try-with-resources 确保资源正确关闭

 

posted @ 2026-01-16 16:33  锐洋智能  阅读(3)  评论(0)    收藏  举报