微信支付后退款遇到的问题

微信支付退款,加载证书过程中遇到了异常问题:

// 指定读取证书格式为PKCS12

KeyStore keyStore = KeyStore.getInstance("PKCS12");
// 读取本机存放的PKCS12证书
FileInputStream instream = new FileInputStream(new File("apiclient_cert.p12"));
try {
// 指定PKCS12的密码(商户ID)
keyStore.load(instream, payRefundEntity.getParterid().toCharArray());

finally {
instream.close();
}

SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, 
payRefundEntity.getParterid().toCharArray()).build();
// 指定TLS版本
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext, 
new String[] { "TLSv1" }, 
null,
SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);

。。。。。。

在进行SSLConnectionSocketFactory 初始化的时候报出异常:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/util/Args
	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.(SSLConnectionSocketFactory.java:189)
	at com.ciii.weixin_v3.pay.WeiXin.doRefund(WeiXin.java:257)
	at com.ciii.weixin_v3.pay.WeiXin.doInBackgroundRefund(WeiXin.java:219)
	at com.ciii.weixin_v3.pay.PayRefundEntity.main(PayRefundEntity.java:54)
Caused by: java.lang.ClassNotFoundException: org.apache.http.util.Args
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 4 more
这是因为httpcore.jar的版本问题造成的,需要提升其版本,该项目是将4.2.4换成了4.3.3就可以了。

你可能感兴趣的:(心得,Java)