Repository navigation
wx-java-open-multi-spring-boot-starter HttpClient 版本依赖问题 #4059
Description
Activity
AbstractWxOpenConfiguration.java
140 ~ 151 行
// 设置自定义的HttpClient超时配置 ApacheHttpClientBuilder clientBuilder = config.getApacheHttpClientBuilder(); if (clientBuilder == null) { clientBuilder = DefaultApacheHttpClientBuilder.get(); } if (clientBuilder instanceof DefaultApacheHttpClientBuilder) { DefaultApacheHttpClientBuilder defaultBuilder = (DefaultApacheHttpClientBuilder) clientBuilder; defaultBuilder.setConnectionTimeout(storage.getConnectionTimeout()); defaultBuilder.setSoTimeout(storage.getSoTimeout()); defaultBuilder.setConnectionRequestTimeout(storage.getConnectionRequestTimeout()); config.setApacheHttpClientBuilder(defaultBuilder); }- linked a pull request that will close this issue修复 wx-java-open-multi-spring-boot-starter 硬编码 HttpClient4 导致启动失败的问题 #4060
on Jul 1, 2026 - added a commit that references this issue
on Jul 1, 2026 还需要在 AbstractWxOpenConfiguration#wxOpenMultiServices 方法中进行 HttpClient5 的超时配置
WxOpenMultiServicesImpl services = new WxOpenMultiServicesImpl(); WxOpenMultiProperties.ConfigStorage storageProps = wxOpenMultiProperties.getConfigStorage(); **// 在首个 WxOpenService 初始化前设置 httpclient 5.x 超时 // DefaultHttpComponentsClientBuilder 是单例,prepare() 仅执行一次 configHttpComponentsTimeout(storageProps);** for (Map.Entry<String, WxOpenSingleProperties> entry : appsMap.entrySet()) { String tenantId = entry.getKey(); WxOpenSingleProperties appProperties = entry.getValue(); WxOpenInRedisTemplateConfigStorage config = configRedisTemplate(); configApp(config, appProperties); configHttp(config, storageProps); // setWxOpenConfigStorage 会触发 initHttp(),使用 httpclient 5.x 构建 CloseableHttpClient WxOpenService wxOpenService = new WxOpenServiceImpl(); wxOpenService.setWxOpenConfigStorage(config); services.addWxOpenService(tenantId, wxOpenService); }/** * 在 httpclient 5.x 单例 builder 上设置超时参数,替代 starter 中无效的 4.x 超时设置。 * * <p> * 必须在 {@code WxOpenServiceImpl.setWxOpenConfigStorage()}(触发 initHttp -> * build -> prepare)之前调用, 因为 prepare() 受 AtomicBoolean 保护仅执行一次。</p> */ private void configHttpComponentsTimeout(WxOpenMultiProperties.ConfigStorage storage) { DefaultHttpComponentsClientBuilder builder = DefaultHttpComponentsClientBuilder.get(); builder.setConnectionTimeout(storage.getConnectionTimeout()); builder.setSoTimeout(storage.getSoTimeout()); builder.setConnectionRequestTimeout(storage.getConnectionRequestTimeout()); }相应的之前 HttpClient4 相关的超时配置代码也要移到循环体之外
请直接提交PR,谢谢
提问前,请确保阅读过项目首页说明以及wiki开发文档相关内容,尤其是常见问题部分。完成内容后,请务必移除包括本句在内的无用内容,以免影响阅读,否则直接关闭,谢谢合作~
另外如果确认属于bug,而且已明确如何修复,请参考贡献指南直接提交PR,省的浪费时间在这里描述问题,非常感谢配合
简要描述
wx-java-open-multi-spring-boot-starter 在 AbstractWxOpenConfiguration.java 中硬编码了 HttpClient4 的相关代码,导致必须要显式引入多一个 HttpClient4 的依赖,否则无法正确启动项目
模块版本情况
日志