1
0
mirror of synced 2026-10-25 01:16:13 +08:00

🎨 #3824 【基础架构】升级到 Apache HttpClient 5.x 作为默认 HTTP 客户端

This commit is contained in:
Copilot
2026-01-06 11:20:58 +08:00
committed by GitHub
parent 987001214d
commit e46da01cc8
20 changed files with 313 additions and 24 deletions

View File

@@ -114,6 +114,52 @@
- **微信开放平台**(`weixin-java-open`)主要用于第三方平台,代公众号或小程序进行开发和管理
---------------------------------
### HTTP 客户端支持
本项目同时支持多种 HTTP 客户端实现,默认推荐使用 **Apache HttpClient 5.x**(最新稳定版本)。
#### 支持的 HTTP 客户端类型
| HTTP 客户端 | 说明 | 配置值 | 推荐程度 |
|------------|------|--------|---------|
| Apache HttpClient 5.x | Apache HttpComponents Client 5.x,最新版本 | `HttpComponents` | ⭐⭐⭐⭐⭐ 推荐 |
| Apache HttpClient 4.x | Apache HttpClient 4.x,向后兼容 | `HttpClient` | ⭐⭐⭐⭐ 兼容 |
| OkHttp | Square OkHttp 客户端 | `OkHttp` | ⭐⭐⭐ 可选 |
| Jodd-http | Jodd 轻量级 HTTP 客户端 | `JoddHttp` | ⭐⭐ 可选 |
#### 配置方式
**Spring Boot 配置示例:**
```properties
# 使用 HttpClient 5.x(推荐,MP/CP/Channel/QiDian 模块默认)
wx.mp.config-storage.http-client-type=HttpComponents
# 使用 HttpClient 4.x(兼容模式,MiniApp 模块默认)
wx.mp.config-storage.http-client-type=HttpClient
# 使用 OkHttp
wx.mp.config-storage.http-client-type=OkHttp
# 使用 Jodd-http
wx.mp.config-storage.http-client-type=JoddHttp
```
**注意**:如果使用 Multi-Starter(如 `wx-java-mp-multi-spring-boot-starter`),枚举值需使用大写下划线格式:
```properties
# Multi-Starter 配置格式
wx.mp.config-storage.http-client-type=HTTP_COMPONENTS # 注意使用大写下划线
```
**注意事项:**
1. **MiniApp 模块**已提供 `HttpComponents`(HttpClient 5.x)类型的配置选项,但当前默认仍为 HttpClient 4.x;如需启用 HttpClient 5.x,请确保所使用的集成模块(如 `wx-java-miniapp-spring-boot-starter`、`wx-java-miniapp-solon-plugin`)版本已支持该选项
2. **MP、Channel、QiDian 模块**已完整支持 HttpClient 5.x,默认推荐使用
3. **CP 模块**的支持情况取决于具体使用的 Starter 版本,请参考对应模块文档
4. 如需使用 OkHttp 或 Jodd-http,需在项目中添加对应的依赖(scope为provided)
5. HttpClient 4.x 和 HttpClient 5.x 可以共存,按需配置即可
---------------------------------
### 版本说明