binarywang/WxJava · error · IllegalArgumentException
微信开放平台 appId 不能为空
Error message
微信开放平台 appId 不能为空
What it means
Thrown by `configApp` in the Spring Boot multi-account Open Platform starter when a tenant's `appId` (componentAppId) is blank. appId is mandatory for an Open Platform component. It is an IllegalArgumentException, distinct from the RuntimeException uniqueness check.
Source
Thrown at spring-boot-starters/wx-java-open-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/open/configuration/services/AbstractWxOpenConfiguration.java:98
wxOpenService = new WxOpenServiceApacheHttpClientImpl();
} else {
wxOpenService = new WxOpenServiceHttpComponentsImpl();
}
wxOpenService.setWxOpenConfigStorage(configStorage);
return wxOpenService;
}
private void configApp(WxOpenInMemoryConfigStorage config, WxOpenSingleProperties appProperties) {
String appId = appProperties.getAppId();
String secret = appProperties.getSecret();
String token = appProperties.getToken();
String aesKey = appProperties.getAesKey();
String apiHostUrl = appProperties.getApiHostUrl();
String accessTokenUrl = appProperties.getAccessTokenUrl();
// appId 和 secret 是必需的
if (StringUtils.isBlank(appId)) {
throw new IllegalArgumentException("微信开放平台 appId 不能为空");
}
if (StringUtils.isBlank(secret)) {
throw new IllegalArgumentException("微信开放平台 secret 不能为空");
}
config.setComponentAppId(appId);
config.setComponentAppSecret(secret);
if (StringUtils.isNotBlank(token)) {
config.setComponentToken(token);
}
if (StringUtils.isNotBlank(aesKey)) {
config.setComponentAesKey(aesKey);
}
// 设置URL配置
config.setApiHostUrl(StringUtils.trimToNull(apiHostUrl));
config.setAccessTokenUrl(StringUtils.trimToNull(accessTokenUrl));
}
View on GitHub (pinned to 1c43293a3c)
Solutions
- Set a non-blank `appId` on the offending open-platform tenant entry.
- Check property name spelling and any `${ENV}` resolution.
- Restart after fixing.
Example fix
# before
wx.open.apps:
tenant-a: { secret: xxxx } # appId missing -> throws
# after
wx.open.apps:
tenant-a: { appId: wxopen001, secret: xxxx } Defensive patterns
Strategy: validation
Validate before calling
// Open multi: assert appId present per tenant before bean creation
for (WxOpenSingleProperties p : appsMap.values()) {
if (StringUtils.isBlank(p.getAppId())) {
throw new IllegalArgumentException("Open platform appId is required for tenant");
}
} Prevention
- Make appId+secret required fields in your config DTO.
- Resolve env var placeholders before validation.
- Add a startup health check for open-platform credentials.
When it happens
Trigger: An entry under `wx.open.apps` whose `appId` is missing, empty, or whitespace, being wired into a WxOpenInMemoryConfigStorage.
Common situations: Forgot to set componentAppId; used the wrong property key (e.g. `componentAppId` instead of `appId`); env-var placeholder resolved to empty.
Related errors
- 微信开放平台 secret 不能为空
- 请确保微信开放平台配置 appId 的唯一性
- 请确保微信视频号配置 appId 的唯一性
- 请确保企业微信配置唯一性[{corpId}]
- 请确保微信小程序配置 appId 的唯一性
AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14).
Data as JSON: /api/errors/824319af37011961.
Report an issue: GitHub.