Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:A616567126 GPT WEB JAVA WxJava WeChat SDK

From Leeroopedia
Knowledge Sources
Domains Networking, Bot_Integration
Last Updated 2026-10-13 18:00 GMT

Overview

WxJava (weixin-java-mp) 4.0.0 with Spring Boot starter for WeChat Official Account integration, providing message handling, QR login, and OAuth.

Description

This environment provides the WeChat integration stack for GPT-WEB-JAVA. It uses WxJava (weixin-java-mp) version 4.0.0 and the corresponding wx-java-mp-spring-boot-starter version 4.0.0 for WeChat Official Account (公众号) integration. The SDK handles: (1) WeChat message callbacks (text, image, event types), (2) QR code ticket generation for scan-to-login, (3) OAuth authorization for cross-platform login binding, (4) Automatic reply message sending, and (5) Media material management. Storage type is configured as `redistemplate`, meaning WeChat access tokens and JS API tickets are cached in Redis rather than in memory or file.

Usage

Use this environment for all WeChat Official Account operations: receiving user messages, sending bot replies, QR scan login, and OAuth token exchange. Required by WxApi, WxServiceImpl, and WxOutServiceImpl.

System Requirements

Category Requirement Notes
OS Any (Java-based) Cross-platform
Hardware Minimal additional resources SDK is lightweight
Network Inbound HTTP from WeChat servers on port 8081 WeChat callback endpoint must be publicly accessible

Dependencies

Java Packages (Maven)

  • `weixin-java-mp` = 4.0.0
  • `wx-java-mp-spring-boot-starter` = 4.0.0

Credentials

The following must be configured in `application.yml`:

  • `wx.mp.app-id`: WeChat Official Account App ID
  • `wx.mp.secret`: WeChat Official Account App Secret
  • `wx.mp.token`: WeChat Official Account verification token (for callback signature validation)
  • `wx.mp.config-storage.type`: Must be `redistemplate` (Redis-based token storage)

Quick Install

# Dependencies are declared in pom.xml:
# com.github.binarywang:weixin-java-mp:4.0.0
# com.github.binarywang:wx-java-mp-spring-boot-starter:4.0.0
# No separate installation needed — included in Maven build

Code Evidence

WeChat MP configuration from `application.yml:26-32`:

wx:
  mp:
    app-id: xxx
    secret: xxx
    config-storage:
      type: redistemplate
    token: xxx

WxJava dependencies from `pom.xml:142-151`:

<dependency>
    <groupId>com.github.binarywang</groupId>
    <artifactId>weixin-java-mp</artifactId>
    <version>4.0.0</version>
</dependency>
<dependency>
    <groupId>com.github.binarywang</groupId>
    <artifactId>wx-java-mp-spring-boot-starter</artifactId>
    <version>4.0.0</version>
</dependency>

Common Errors

Error Message Cause Solution
`Invalid signature` WeChat callback token mismatch Verify `wx.mp.token` matches the token configured in WeChat Official Account admin
`Access token invalid` Redis storage not configured or Redis down Ensure `config-storage.type=redistemplate` and Redis is running
`AppID not configured` `wx.mp.app-id` is placeholder `xxx` Replace with actual WeChat App ID in application.yml
`40163 code been used` OAuth code reused Each QR scan generates a one-time code; ensure no retry with same code

Compatibility Notes

  • WxJava 4.x: Version 4.0.0 is pinned; upgrading to 4.1+ may require API changes.
  • Storage type: Uses Redis (`redistemplate`) for token storage; in-memory storage would lose tokens on restart in multi-instance deployments.
  • WeChat Pay: WeChat Pay v3 is handled separately by WxPayUtil using direct HTTP, not through the WxJava SDK.
  • Public URL: WeChat callback endpoint must be publicly accessible; use Nginx reverse proxy with HTTPS for production.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment