微信服务端 Java 开发工具包,覆盖微信支付、公众号、小程序、企业微信、开放平台、视频号、微信小店等全场景。
|
|
赞助商招募中,欢迎联系合作(联系方式见下方 社区交流与支持)。
- 全生态微信服务端能力:覆盖微信公众号、微信小程序、微信支付(V2/V3)、企业微信、开放平台、视频号、微信小店等主流微信业务模块。
- 主流框架开箱即用:内置官方 Spring Boot Starters(支持单账号与多账号)和 Solon Plugins,同时提供 Quarkus 集成指南 与 GraalVM Native Image 辅助支持(
weixin-graal)。 - 灵活的存储与 HTTP 适配:支持 Memory、Jedis、RedisTemplate、Redisson 等多配置存储,支持 Apache HttpClient 4.x / 5.x、OkHttp、Jodd-Http 切换。
- 统一版本管理:提供
wx-java-bom统一管理多模块依赖版本,基础环境要求JDK 8+。 - 原生 AI 编程支持:内置面向 AI 编程智能体的 5 个标准
SKILL,辅助模块选型、项目接入、故障排查、接口贡献与升级迁移。
| 业务场景 | 核心模块 (artifactId) |
Spring Boot Starter(单账号 / 多账号) | Solon Plugin |
|---|---|---|---|
| 微信公众号 | weixin-java-mp |
wx-java-mp-spring-boot-starter / wx-java-mp-multi-spring-boot-starter |
wx-java-mp-solon-plugin / wx-java-mp-multi-solon-plugin |
| 微信小程序 | weixin-java-miniapp |
wx-java-miniapp-spring-boot-starter / wx-java-miniapp-multi-spring-boot-starter |
wx-java-miniapp-solon-plugin / wx-java-miniapp-multi-solon-plugin |
| 微信支付(V2/V3) | weixin-java-pay |
wx-java-pay-spring-boot-starter / wx-java-pay-multi-spring-boot-starter |
wx-java-pay-solon-plugin |
| 企业微信 | weixin-java-cp |
wx-java-cp-spring-boot-starter / wx-java-cp-multi-spring-boot-starter / wx-java-cp-tp-multi-spring-boot-starter |
wx-java-cp-solon-plugin / wx-java-cp-multi-solon-plugin |
| 微信开放平台(第三方平台) | weixin-java-open |
wx-java-open-spring-boot-starter / wx-java-open-multi-spring-boot-starter |
wx-java-open-solon-plugin |
| 微信视频号 | weixin-java-channel |
wx-java-channel-spring-boot-starter / wx-java-channel-multi-spring-boot-starter |
wx-java-channel-solon-plugin / wx-java-channel-multi-solon-plugin |
| 微信小店(独立新模块) | weixin-java-store |
wx-java-store-spring-boot-starter / wx-java-store-multi-spring-boot-starter |
wx-java-store-solon-plugin / wx-java-store-multi-solon-plugin |
- 微信小店模块说明:微信小店已拆分为独立模块
weixin-java-store,原有weixin-java-channel中的小店接口已标记为@Deprecated,迁移方式详见 微信小店模块迁移指南。 - 移动应用(iOS/Android)接入说明:客户端登录、分享等能力需集成微信官方移动端 SDK,本项目为服务端 SDK;服务端 OAuth 网页授权可使用
weixin-java-open,支付使用weixin-java-pay。weixin-java-open主要用于第三方平台代公众号或小程序进行开发和管理。
展开查看扩展与辅助模块(企点 / 智能对话 / GraalVM / BOM)
| 场景 / 用途 | artifactId |
配套集成 / 说明 |
|---|---|---|
| 腾讯企点 | weixin-java-qidian |
对应 wx-java-qidian-spring-boot-starter、wx-java-qidian-solon-plugin |
| 微信智能对话 | weixin-java-aispeech |
微信对话开放平台服务端 SDK |
| GraalVM Native Image | weixin-graal |
配合生成 native-image 配置的辅助模块 |
| 依赖版本管理 | wx-java-bom |
统一管理 WxJava 各核心模块与 Starter/Plugin 版本 |
最新稳定版为 4.8.6(GitHub Releases · )。
wx-java-bom 从 4.8.3.B(正式版 4.8.4+)开始提供,导入后各模块与 Starter 无需重复指定版本号:
<properties>
<wx-java.version>4.8.6</wx-java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java-bom</artifactId>
<version>${wx-java.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>之后按需引入核心模块或 Starter 即可:
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java-mp-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java-pay-spring-boot-starter</artifactId>
</dependency><dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>wx-java-mp-spring-boot-starter</artifactId>
<!-- 如不使用 Spring Boot Starter,可替换为对应的核心模块,如 weixin-java-mp -->
<version>4.8.6</version>
</dependency>Gradle(Groovy / Kotlin DSL)引入方式
Groovy DSL (build.gradle):
dependencies {
implementation platform('com.github.binarywang:wx-java-bom:4.8.6')
implementation 'com.github.binarywang:wx-java-mp-spring-boot-starter'
implementation 'com.github.binarywang:wx-java-pay-spring-boot-starter'
}Kotlin DSL (build.gradle.kts):
dependencies {
implementation(platform("com.github.binarywang:wx-java-bom:4.8.6"))
implementation("com.github.binarywang:wx-java-mp-spring-boot-starter")
implementation("com.github.binarywang:wx-java-pay-spring-boot-starter")
}Spring Boot Starter 示例:微信公众号(获取 AccessToken)
- 在
application.yml中配置公众号参数:
wx:
mp:
app-id: your-app-id
secret: your-secret- 直接注入
WxMpService调用 API:
@RestController
@RequiredArgsConstructor
public class WxMpDemoController {
private final WxMpService wxMpService;
@GetMapping("/mp/token")
public String getToken() throws WxErrorException {
return wxMpService.getAccessToken();
}
}Spring Boot Starter 示例:微信支付 V3(查询订单)
- 在
application.yml中配置商户证书与 V3 密钥(V2 与服务商配置见 wx-java-pay-spring-boot-starter):
wx:
pay:
appId: your-app-id
mchId: your-mch-id
apiV3Key: your-api-v3-key
certSerialNo: your-cert-serial-no
privateKeyPath: classpath:cert/apiclient_key.pem
privateCertPath: classpath:cert/apiclient_cert.pem- 注入
WxPayService调用 V3 接口:
@Service
@RequiredArgsConstructor
public class WxPayDemoService {
private final WxPayService wxPayService;
public WxPayOrderQueryV3Result queryOrder(String outTradeNo) throws WxPayException {
return wxPayService.queryOrderV3(null, outTradeNo);
}
}原生 Java 示例:公众号(MP)与小程序(MiniApp)
公众号(MP)获取 AccessToken:
WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
config.setAppId("your-app-id");
config.setSecret("your-secret");
WxMpService wxMpService = new WxMpServiceImpl();
wxMpService.setWxMpConfigStorage(config);
String accessToken = wxMpService.getAccessToken();
System.out.println(accessToken);小程序(MiniApp)code2Session:
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
config.setAppid("your-app-id");
config.setSecret("your-secret");
WxMaService wxMaService = new WxMaServiceImpl();
wxMaService.setWxMaConfig(config);
WxMaJscode2SessionResult result = wxMaService.getUserService().getSessionInfo("js-code");
System.out.println(result.getOpenid());仓库的 skills 目录提供面向 WxJava 用户和贡献者的通用 SKILL,以 SKILL.md 为入口,支持主流 AI 编程智能体直接安装使用。
支持远程安装 SKILL 的智能体,可直接使用自然语言指令安装,例如:
安装 https://github.com/binarywang/WxJava/tree/develop/skills/wxjava-integration-guide 中的技能。
可安装的 SKILL 包括:
- 模块选择(wxjava-module-selector)
- 接入指南(wxjava-integration-guide)
- 故障排查(wxjava-troubleshooter)
- 接口贡献(wxjava-api-contributor)
- 升级迁移(wxjava-upgrade-guide)
重启或新建智能体会话后,即可按需触发,例如:使用 wxjava-integration-guide 为我的 Spring Boot 项目接入微信支付。
不支持远程安装?查看本地复制安装方式
可将所需的 skills/wxjava-* 目录复制到智能体的 SKILL 目录或工作区配置目录(具体目录请以其官方文档为准)。以 Codex 为例:
git clone https://github.com/binarywang/WxJava.git
mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills"
cp -R WxJava/skills/wxjava-* "${CODEX_HOME:-$HOME/.codex}/skills/"如果已在本仓库根目录,可直接执行:
mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills"
cp -R skills/wxjava-* "${CODEX_HOME:-$HOME/.codex}/skills/"- 开发文档 Wiki:GitHub Wiki / Gitee Wiki(部分文档可能未能及时更新,欢迎上报或自行修正)
- Demo 项目参考:Demo 项目列表(本项目仅提供服务端 SDK,未包含 Web 实现,可参考 Demo 或模块单元测试快速上手)
- AI 文档问答:DeepWiki
- 微信小店模块迁移指南(channel → store)
- HttpClient 4.x / 5.x 升级与切换指南
- 微信支付新版商家转账接入指南
- Quarkus 集成支持
- Spring Boot 多租户 / 多账号模式说明
- 企业微信会话存档安全用法
- weixin-java-miniapp · weixin-java-pay · weixin-java-mp · weixin-java-common · weixin-java-cp · weixin-java-open
- JDK 版本要求:最新版本最低要求
JDK 8;使用JDK 7请选择3.8.0及以前版本;JDK 6用户请参考 weixin-java-tools-for-jdk6。 - 源码编译依赖:为简化实体类代码,本 SDK 使用了
Lombok;阅读或调试源码前不了解的同学可先阅读 Lombok 介绍文章。
点此展开查看版本发布规则与各模块最新版本
想获取 QQ 群 / 微信群 / 钉钉企业群加入方式,或接收版本更新通知与微信开发技术文章,请扫码关注 WxJava 公众号(也可在微信中搜索 weixin-java-tools 或 WxJava):
- 钉钉技术交流群:
32206329(技术交流 2 群)、30294972(技术交流 1 群,已满)、35724728(通知群,实时同步 GitHub 变更记录)。
- 有新功能需求、发现 BUG 或微信官方接口变更,欢迎在 GitHub Issues 提交反馈。
- 提问前请先查阅 开发文档 Wiki 的常见问题部分,并参考 提问的智慧;粘贴大段代码或异常堆栈时建议使用 Issue 代码块折叠(
<details>)或 GitHub Gist。
- 提交 PR 前请务必先阅读 代码贡献指南。
- 贡献源码视频教程(友情提供:程序员小山与Bug):贡献源码全过程(上集)、贡献源码全过程(下集)。
- 项目合作洽谈:请联系微信
binary0000(搜索添加并注明来意;SDK 技术问题请通过社区群或 Issue 讨论,请勿加此微信)。 - 赞赏与评分:如果本项目对您有帮助,欢迎前往 Gitee 项目首页 页尾点击“捐助”进行打赏,或在 开源中国页面 留言评分 🙂。
- 同步托管仓库:GitHub · Gitee 码云 · GitCode
完整案例登记列表,请【访问这里】查看,欢迎登记更多的案例。
以下为节选的部分案例,点此展开查看
- 基于微信公众号的签到、抽奖、发送弹幕程序:https://github.com/workcheng/weiya
- Jeepay 支付系统:https://gitee.com/jeequan/jeepay
- 微同商城:https://gitee.com/fuyang_lipengjun/platform
- 微信点餐系统:https://github.com/sqmax/springboot-project
- 专注批量推送的小而美的工具:https://github.com/rememberber/WePush
- yshop意象商城系统:https://gitee.com/guchengwuyue/yshopmall
- wx-manage(微信公众号管理项目):https://github.com/niefy/wx-manage
- 基于若依开发的微信公众号管理系统:https://gitee.com/joolun/JooLun-wx
- SAAS微信小程序电商:https://gitee.com/wei-it/weiit-saas
- mall4j 电商商城系统:https://gitee.com/gz-yami/mall4j
- (京东)友家铺子,友家铺子店长版,京粉精选
- 喵星人贴吧助手(扫码关注)
- 树懒揽书+
- 广廉快线,鹏城巴士等
- 当燃挑战、sportlight轻灵运动
- 360考试宝典
- 民医台
- 来一团商家版
- 史必达(史丹利)
- 嘀嗒云印
- 维沃吼吼
- 王朝社区(比亚迪新能源社区)
- 极吼吼手机上门回收换新
- 未来信封
- 5G惠享
- 生菜wordpress转小程序
- 丽日购
- 中国电信上海网厅(sh_189)
- E答平台
- 宁夏生鲜365
- 通服货滴
- 神龙养车
- 沃音乐商务智能
- 光环云社群
- 手机排队
- 全民约跑健身便利店
- 民医台
- YshopMall
- 好行景区直通车以及全国40多个公众号
- 我奥篮球公众号
- 未来信封官微
- 银川智云问诊
- 5G惠享
- HTC企业微信
- 掌上史丹利
- 药店益
- 高善人力资源
- 小猪餐餐
- 餐饮系统
- 微信公众号管理系统:http://demo.joolun.com
- 锐捷网络:Saleslink
WxJava荣获GitCode2024 年度十大开源社区奖项- 所有贡献者列表请在此处查看,感谢每一份 PR 与反馈!