3.8.0的 WxRedisOps 打成jar包后会启动失败 ### 模块版本情况 * WxJava 模块名: 3.8.0 * WxJava 版本号:3.8.0 升级3.8之前采用本地内存配置的方式启动,代码如下 ```java @Bean public WxMpService wxMpService(WechatProperties wechatProperties) { WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl(); configStorage.setAppId(wechatProperties.getAppId()); configStorage.setSecret(wechatProperties.getSecret()); configStorage.setToken(wechatProperties.getToken()); WxMpService wxMpService = new WxMpServiceImpl(); wxMpService.setWxMpConfigStorage(configStorage); return wxMpService; } ``` 升级3.8.0之后,本地已经确认移除了jedis依赖,使用 StringRedisTemplate 的方式,代码如下 ```java @Bean public WxMpService wxMpService(WechatProperties wechatProperties, StringRedisTemplate stringRedisTemplate) { RedisTemplateWxRedisOps wxRedisOps = new RedisTemplateWxRedisOps(stringRedisTemplate); WxMpRedisConfigImpl configStorage = new WxMpRedisConfigImpl(wxRedisOps, "wx"); configStorage.setAppId(wechatProperties.getAppId()); configStorage.setSecret(wechatProperties.getSecret()); configStorage.setToken(wechatProperties.getToken()); WxMpService wxMpService = new WxMpServiceImpl(); wxMpService.setWxMpConfigStorage(configStorage); return wxMpService; } ``` ### 日志 [报错日志](https://paste.ubuntu.com/p/j6YbtQ6hFN/)
Activity
binarywang commentedon Jun 5, 2020
暂时把jedis加回来吧,目前的代码需要依赖,没有找到好的办法处理,如果你有,欢迎提交PR
yuxicun commentedon Jun 5, 2020
我总结了下,必须添加
redis.clients
jedis
2.10.2
这个才能成功,版本是3.3的不行啊,跟踪了下代码,发现wx需要依赖2版本的
binarywang commentedon Jun 6, 2020
确实目前依赖的是2.x版本的jedis
lkqm commentedon Jun 6, 2020
目前的解决只能把
WxMpRedisConfigImpl的这个构造函数移除掉WxMpRedisConfigImpl(JedisPool jedisPool), 这样老本本就存在兼容问题。这里很奇怪, 即使我调用另外一个构造函数, 在打包后的jar执行中, 依然会去加载参数为JedisPool这个类.
binarywang commentedon Jun 6, 2020
我觉得可以不必兼容老版本,如果想使用老版本,自行去修改实现吧
lkqm commentedon Jun 8, 2020
@binarywang 之前的结论是错的, 最后测试发现spring-boot加载
WxMpStorageAutoConfiguration会去反射获取所有方法, 触发了类加载, 复现代码如下:目前没有办法解决, 也就是说jdk反射机制会触发JedisPool类加载, 不确定是不是jdk的一个bug
环境:
日志: https://paste.ubuntu.com/p/NMjGDkD3TV/