Pre Merge pull request !245 from wuKong/feat/feat(pay)-jre21支付回调v2解析失败

pull/245/MERGE
wuKong 2026-05-03 11:36:44 +00:00 committed by Gitee
commit b32c4e0fd4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.pay.framework.pay.config;
import com.thoughtworks.xstream.XStream;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
import org.springframework.context.annotation.Configuration;
/**
* XStream V2
*
* @author wuKong
*/
@Slf4j
@Configuration
public class PayXStreamConfig {
@PostConstruct
public void init() {
log.info("初始化 XStream 安全配置,允许微信支付类的反序列化");
try {
XStream xstream = XStreamInitializer.getInstance();
// 添加白名单
// Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException:
// com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult
xstream.allowTypesByWildcard(new String[] {
"com.github.binarywang.wxpay.bean.notify.**",
"com.github.binarywang.wxpay.bean.result.**",
"com.github.binarywang.wxpay.bean.request.**",
"com.github.binarywang.wxpay.bean.order.**"});
log.info("XStream 安全配置初始化成功");
} catch (Exception e) {
log.error("XStream 安全配置初始化失败", e);
}
}
}