参考:Java 微信支付 继承 WXPayConfig 类 getWXPayDomain() 方法 重写 遗漏
Java开发微信支付使用wxpay-sdk中遇到的坑(一)
MyWxPayConfig配置类代码,应该是extends继承,而不是implement实现
package com.tj.qywx.config;import com.github.wxpay.sdk.IWXPayDomain;import com.github.wxpay.sdk.WXPayConfig;import com.tj.base.service.BaseNumvarService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import java.io.*;public class MyWxPayConfig extends WXPayConfig {@Autowiredprivate BaseNumvarService baseNumvarService;private byte[] certData;@Value("${cert.path}") //读取yaml文件里设置的地址信息private String path;public MyWxPayConfig() throws Exception {String certPath = this.path;File file = new File(certPath);InputStream certStream = new FileInputStream(file);this.certData = new byte[(int) file.length()];certStream.read(this.certData);certStream.close();}@Overridepublic String getAppID() {return baseNumvarService.getCorpid();}@Overridepublic String getMchID() {return baseNumvarService.getMchId();}@Overridepublic String getKey() {return baseNumvarService.getAPIv2();}@Overridepublic InputStream getCertStream() {ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);return certBis;}@Overridepublic IWXPayDomain getWXPayDomain() {return null;}}
