WxJava README

The project's README from github.com/binarywang/WxJava. As one markdown file: README.md.

WxJava - 微信开发 Java SDK

微信服务端 Java 开发工具包,覆盖微信支付、公众号、小程序、企业微信、开放平台、视频号、微信小店等全场景。

Github Gitee GitCode

GitHub release Maven Central Maven Tests License 使用IntelliJ IDEA开发维护 Ask DeepWiki

核心特性 · 模块选型 · 快速开始 · AI 编程 SKILL · 文档与资源 · 社区交流 · 特别赞助


特别赞助

计全支付Jeepay,开源支付系统 CRMEB

WildAI - ChatGPT Plus / Claude Pro 订阅与续费,优惠码 COOLOK 享专属折扣

赞助商招募中,欢迎联系合作(联系方式见下方 社区交流与支持)。


核心特性


模块选型

业务场景 核心模块 (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
展开查看扩展与辅助模块(企点 / 智能对话 / 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 · Maven Central)。

1. 引入依赖

方式一:使用 BOM 统一管理版本(推荐,多模块场景)

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>

方式二:直接引入单个模块 / Spring Boot Starter

<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")
}

2. 最小示例

Spring Boot Starter 示例:微信公众号(获取 AccessToken)
  1. 在 application.yml 中配置公众号参数:
wx:
  mp:
    app-id: your-app-id
    secret: your-secret
  1. 直接注入 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(查询订单)
  1. 在 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
  1. 注入 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());

AI 编程 SKILL

仓库的 skills 目录提供面向 WxJava 用户和贡献者的通用 SKILL,以 SKILL.md 为入口,支持主流 AI 编程智能体直接安装使用。

支持远程安装 SKILL 的智能体,可直接使用自然语言指令安装,例如:

安装 https://github.com/binarywang/WxJava/tree/develop/skills/wxjava-integration-guide 中的技能。

可安装的 SKILL 包括:

重启或新建智能体会话后,即可按需触发,例如:使用 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/"

文档与资源

核心文档与 Demo

专题指南(docs/)

在线 Javadoc

环境与源码说明


版本与发布说明

点此展开查看版本发布规则与各模块最新版本
  1. 正式版按需定期发布(如 4.8.0~4.8.6),发布时将 develop 分支合并至 release 分支并打正式版本号(X.Y.Z);遇到重大问题修复会及时发布新版本,欢迎提交 PR。
  2. 测试版版本号带 .B 后缀(如 4.8.6.B),对应 develop 分支中的开发版本。
  3. 普通 develop 提交仅执行测试,不自动发布;需要提前验证修复时,维护者可在 GitHub Actions 手动发布 x.x.x-时间戳 版本。
  4. 总包最新版本为 Maven Central,也可直接查看各主要模块的 Central 仓库版本:

小程序解密与 Bouncy Castle 依赖迁移


社区交流

公众号与技术交流群

想获取 QQ 群 / 微信群 / 钉钉企业群加入方式,或接收版本更新通知与微信开发技术文章,请扫码关注 WxJava 公众号(也可在微信中搜索 weixin-java-tools 或 WxJava):

WxJava 公众号二维码

提问与反馈

参与贡献

商务合作、赞赏与代码托管


应用案例

完整案例登记列表,请【访问这里】查看,欢迎登记更多的案例。

以下为节选的部分案例,点此展开查看

开源项目:

小程序:

  • (京东)友家铺子,友家铺子店长版,京粉精选
  • 喵星人贴吧助手(扫码关注)
  • 树懒揽书+
  • 广廉快线,鹏城巴士等
  • 当燃挑战、sportlight轻灵运动
  • 360考试宝典
  • 民医台
  • 来一团商家版
  • 史必达(史丹利)
  • 嘀嗒云印
  • 维沃吼吼
  • 王朝社区(比亚迪新能源社区)
  • 极吼吼手机上门回收换新
  • 未来信封
  • 5G惠享
  • 生菜wordpress转小程序
  • 丽日购

公众号:

  • 中国电信上海网厅(sh_189)
  • E答平台
  • 宁夏生鲜365
  • 通服货滴
  • 神龙养车
  • 沃音乐商务智能
  • 光环云社群
  • 手机排队
  • 全民约跑健身便利店
  • 民医台
  • YshopMall
  • 好行景区直通车以及全国40多个公众号
  • 我奥篮球公众号
  • 未来信封官微
  • 银川智云问诊
  • 5G惠享

企业微信:

  • HTC企业微信
  • 掌上史丹利
  • 药店益

其他:

  • 高善人力资源
  • 小猪餐餐
  • 餐饮系统
  • 微信公众号管理系统:http://demo.joolun.com
  • 锐捷网络:Saleslink

贡献者与社区荣誉

Featured|HelloGitHub binarywang/WxJava | 趋势转变 Star History

GitHub Stargazers over time

Star History Chart

WxJava (binarywang/WxJava)

miniprogram
Searching Database…

33.2K ·GitHub
What is this?WxJava is an open-source Java SDK for WeChat backend development, covering WeChat Pay, the Open Platform, Official Accounts, WeCom (Enterprise WeChat), Channels, and Mini Programs.
Is it a library I add to my server, or a service I deploy?It is a plain SDK toolkit, not a deployable service: you add it as a Maven or Gradle dependency, and it provides no web implementation of its own.
How do I start using it in my project?Pick the module for your scenario, add its Maven dependency (or the wx-java-bom to manage versions across several modules), then follow a minimal example to initialize and call APIs.
What Java version do I need?The latest versions require JDK 8 or newer; JDK 7 users must fall back to WxJava 3.8.0 or earlier, and the source uses Lombok if you want to read or build it yourself.
Can it handle WeChat login and sharing inside my mobile app?No — it is server-side only. In-app WeChat login and sharing on iOS/Android need WeChat's official client SDKs; on the server, OAuth web authorization goes through the weixin-java-open module.
Which module do I need for my WeChat scenario?Official Accounts use weixin-java-mp, Mini Programs weixin-java-miniapp, payments weixin-java-pay, WeCom (Enterprise WeChat) weixin-java-cp, third-party platform work weixin-java-open, and Channels or WeChat Store weixin-java-channel.
What are the bundled AI coding agent SKILLs for?The skills directory ships SKILL.md guides covering module selection, integration, troubleshooting, API contribution and upgrade migration. Agents with remote install accept a natural-language command; otherwise copy a skills/wxjava-* folder into your agent's skill directory.
Creator
binarywang
Size
20.4 MB
Stars
33.2K
Age
10y
Commits · 90 Days