为 wx-java-mp-spring-boot-starter 添加 HttpComponents (httpclient5) 支持 - #3782
Conversation
…兼容 Spring Boot 3 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
binarywang
commented
Nov 28, 2025
@copilot WxMpServiceHttpComponentsImpl 这个类是存在的吗?你是不是得先实现这个类 |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
本 PR 为 wx-java-mp-spring-boot-starter 和 wx-java-mp-multi-spring-boot-starter 添加了对 Apache HttpClient 5.x(HttpComponents)的支持,解决 Spring Boot 3 升级时因强制使用 httpclient5 而导致的兼容性问题。核心库 weixin-java-mp 已提供 WxMpServiceHttpComponentsImpl 实现,本次修改将该选项暴露给 Spring Boot starter 用户使用。
关键变更:
- 在
HttpClientType枚举中新增HttpComponents值 - 在自动配置类中添加对应的实例化逻辑
- 在 pom.xml 中添加 httpclient5 依赖(scope: provided)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/enums/HttpClientType.java | 为 HttpClientType 枚举添加 HttpComponents 值,用于标识 Apache HttpClient 5.x 实现 |
| spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/mp/config/WxMpServiceAutoConfiguration.java | 在自动配置类的 switch 语句中添加 HttpComponents case 分支,并实现相应的工厂方法 |
| spring-boot-starters/wx-java-mp-spring-boot-starter/pom.xml | 添加 httpclient5 依赖(scope: provided),与其他 HTTP 客户端依赖保持一致 |
| spring-boot-starters/wx-java-mp-multi-spring-boot-starter/pom.xml | 为多账号版本 starter 添加 httpclient5 依赖(代码逻辑已支持 HTTP_COMPONENTS,仅补充依赖声明) |
| <dependency> | ||
| <groupId>org.apache.httpcomponents.client5</groupId> | ||
| <artifactId>httpclient5</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> |
There was a problem hiding this comment.
README.md 中的文档需要更新,以包含新的 HttpComponents 选项。
当前第 30 行显示:
wx.mp.config-storage.http-client-type=httpclient # http客户端类型: HttpClient(默认), OkHttp, JoddHttp建议更新为:
wx.mp.config-storage.http-client-type=httpclient # http客户端类型: HttpClient(默认), OkHttp, JoddHttp, HttpComponents注意:HttpComponents 对应 Apache HttpClient 5.x,适用于 Spring Boot 3 环境。
There was a problem hiding this comment.
@copilot apply changes based on this feedback
Spring Boot 3 强制使用 httpclient5,而当前 starter 仅支持 httpclient4,导致升级后无法运行。核心库已有
WxMpServiceHttpComponentsImpl实现,本 PR 为 starter 暴露该选项。修改内容
wx-java-mp-spring-boot-starter
HttpClientType枚举添加HttpComponents值WxMpServiceAutoConfiguration添加对应 case 分支pom.xml添加 httpclient5 依赖 (scope: provided)wx-java-mp-multi-spring-boot-starter
pom.xml添加 httpclient5 依赖(代码已支持HTTP_COMPONENTS)使用方法
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.