File tree Expand file tree Collapse file tree 10 files changed +66
-6
lines changed
Expand file tree Collapse file tree 10 files changed +66
-6
lines changed Original file line number Diff line number Diff line change 4343
4444### 对现有项目
4545- ** 向后兼容** :不需要修改任何代码
46- - HttpClient 4.x 依然可用,项目同时包含两个版本的依赖
47- - 如果希望继续使用 HttpClient 4.x,只需在配置中显式指定
46+ - 如果希望继续使用 HttpClient 4.x,只需在配置中显式指定,pay 模块会自动包含 httpclient4 依赖(因为某些接口必须使用 httpclient4)
47+ 其他模块(mp、miniapp、cp、open、channel、qidian)如果需要使用 httpclient4,必须显式在项目中添加 httpclient4 依赖
4848
4949## 迁移步骤
5050
@@ -94,10 +94,10 @@ WxMpService wxMpService = new WxMpServiceHttpClientImpl();
9494A: 不会。项目保持完全向后兼容,HttpClient 4.x 的所有实现都保持不变。
9595
9696### Q: 我需要修改代码吗?
97- A: 大多数情况下不需要。如果希望继续使用 HttpClient 4.x,只需在配置中指定 ` http-client-type=HttpClient ` 即可 。
97+ A: 大多数情况下不需要。如果希望继续使用 HttpClient 4.x,只需在配置中指定 ` http-client-type=HttpClient ` ,并引入 HttpClient 4.x 依赖即可 。
9898
9999### Q: 我可以在同一个项目中同时使用两个版本吗?
100- A: 可以。不同的模块可以配置使用不同的 HTTP 客户端。例如,MP 模块使用 HttpClient 5.x,MiniApp 模块默认使用 HttpClient 4.x,但也可以按需配置为 HttpClient 5.x。
100+ A: 可以。不同的模块可以配置使用不同的 HTTP 客户端。例如,MP 模块使用 HttpClient 5.x,pay 模块部分接口仍使用 HttpClient 4.x,但也可以按需配置为 HttpClient 5.x。
101101
102102### Q: 如何排除不需要的依赖?
103103A: 如果只想使用一个版本,可以在 ` pom.xml ` 中排除另一个:
@@ -196,4 +196,4 @@ weixin-java-common/
196196- ✅ ** 推荐使用 HttpClient 5.x** :性能更好,功能更强
197197- ✅ ** 向后兼容** :可以继续使用 HttpClient 4.x
198198- ✅ ** 灵活配置** :支持多种 HTTP 客户端,按需选择
199- - ✅ ** 平滑迁移** :无需修改代码,仅需配置即可
199+ - ✅ ** 平滑迁移** :无需修改代码,仅需配置,若不使用 HttpClient 5.x ,引入其他依赖即可
Original file line number Diff line number Diff line change 136136
137137 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
138138 <httpclient .version>4.5.13</httpclient .version>
139- <httpclient5 .version>5.5</httpclient5 .version>
139+ <httpclient5 .version>5.5.2 </httpclient5 .version>
140140 <jetty .version>9.4.57.v20241219</jetty .version> <!-- 这个不能用10以上的版本,不支持jdk8-->
141141 </properties >
142142 <dependencyManagement >
Original file line number Diff line number Diff line change 2929 <artifactId >jodd-http</artifactId >
3030 <scope >provided</scope >
3131 </dependency >
32+ <dependency >
33+ <groupId >org.apache.httpcomponents</groupId >
34+ <artifactId >httpclient</artifactId >
35+ <scope >provided</scope >
36+ </dependency >
37+ <dependency >
38+ <groupId >org.apache.httpcomponents</groupId >
39+ <artifactId >httpmime</artifactId >
40+ <scope >provided</scope >
41+ </dependency >
3242 <dependency >
3343 <groupId >org.apache.httpcomponents.client5</groupId >
3444 <artifactId >httpclient5</artifactId >
Original file line number Diff line number Diff line change 3434 <dependency >
3535 <groupId >org.apache.httpcomponents</groupId >
3636 <artifactId >httpclient</artifactId >
37+ <scope >provided</scope >
3738 <exclusions >
3839 <exclusion >
3940 <artifactId >commons-logging</artifactId >
4445 <dependency >
4546 <groupId >org.apache.httpcomponents</groupId >
4647 <artifactId >httpmime</artifactId >
48+ <scope >provided</scope >
4749 </dependency >
4850
4951 <dependency >
Original file line number Diff line number Diff line change 3030 <artifactId >okhttp</artifactId >
3131 <scope >provided</scope >
3232 </dependency >
33+ <dependency >
34+ <groupId >org.apache.httpcomponents</groupId >
35+ <artifactId >httpclient</artifactId >
36+ <scope >provided</scope >
37+ </dependency >
3338 <dependency >
3439 <groupId >org.apache.httpcomponents.client5</groupId >
3540 <artifactId >httpclient5</artifactId >
Original file line number Diff line number Diff line change 3131 <artifactId >okhttp</artifactId >
3232 <scope >provided</scope >
3333 </dependency >
34+ <dependency >
35+ <groupId >org.apache.httpcomponents</groupId >
36+ <artifactId >httpclient</artifactId >
37+ <scope >provided</scope >
38+ </dependency >
39+ <dependency >
40+ <groupId >org.apache.httpcomponents</groupId >
41+ <artifactId >httpmime</artifactId >
42+ <scope >provided</scope >
43+ </dependency >
3444 <dependency >
3545 <groupId >org.apache.httpcomponents.client5</groupId >
3646 <artifactId >httpclient5</artifactId >
Original file line number Diff line number Diff line change 3131 <artifactId >okhttp</artifactId >
3232 <scope >provided</scope >
3333 </dependency >
34+ <dependency >
35+ <groupId >org.apache.httpcomponents</groupId >
36+ <artifactId >httpclient</artifactId >
37+ <scope >provided</scope >
38+ </dependency >
39+ <dependency >
40+ <groupId >org.apache.httpcomponents</groupId >
41+ <artifactId >httpmime</artifactId >
42+ <scope >provided</scope >
43+ </dependency >
3444 <dependency >
3545 <groupId >org.apache.httpcomponents.client5</groupId >
3646 <artifactId >httpclient5</artifactId >
Original file line number Diff line number Diff line change 4848 <artifactId >okhttp</artifactId >
4949 <scope >provided</scope >
5050 </dependency >
51+ <dependency >
52+ <groupId >org.apache.httpcomponents</groupId >
53+ <artifactId >httpclient</artifactId >
54+ <scope >provided</scope >
55+ </dependency >
56+ <dependency >
57+ <groupId >org.apache.httpcomponents</groupId >
58+ <artifactId >httpmime</artifactId >
59+ <scope >provided</scope >
60+ </dependency >
5161 <dependency >
5262 <groupId >org.apache.httpcomponents.client5</groupId >
5363 <artifactId >httpclient5</artifactId >
Original file line number Diff line number Diff line change 3434 <artifactId >jodd-util</artifactId >
3535 <version >6.1.0</version >
3636 </dependency >
37+ <dependency >
38+ <groupId >org.apache.httpcomponents</groupId >
39+ <artifactId >httpclient</artifactId >
40+ </dependency >
41+ <dependency >
42+ <groupId >org.apache.httpcomponents</groupId >
43+ <artifactId >httpmime</artifactId >
44+ </dependency >
3745 <dependency >
3846 <groupId >org.apache.httpcomponents.client5</groupId >
3947 <artifactId >httpclient5</artifactId >
Original file line number Diff line number Diff line change 3131 <artifactId >okhttp</artifactId >
3232 <scope >provided</scope >
3333 </dependency >
34+ <dependency >
35+ <groupId >org.apache.httpcomponents</groupId >
36+ <artifactId >httpclient</artifactId >
37+ <scope >provided</scope >
38+ </dependency >
3439 <dependency >
3540 <groupId >org.apache.httpcomponents.client5</groupId >
3641 <artifactId >httpclient5</artifactId >
You can’t perform that action at this time.
0 commit comments