From f458e9e3cb022a637513720b7851a3c95d646c20 Mon Sep 17 00:00:00 2001 From: yang <2119157836@qq.com> Date: Mon, 10 Mar 2025 17:16:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor(mcwl-pay):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E8=AF=81=E4=B9=A6=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mcwl/pay/service/impl/AliPayServiceImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/AliPayServiceImpl.java b/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/AliPayServiceImpl.java index 603fc08..341d896 100644 --- a/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/AliPayServiceImpl.java +++ b/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/AliPayServiceImpl.java @@ -564,6 +564,11 @@ public class AliPayServiceImpl implements AliPayService { public AlipayConfig getAlipayConfig() throws FileNotFoundException { + // 使用 ClassPathResource 获取资源 + ClassPathResource appCertResource = new ClassPathResource(aliConfig.getAppCertPath()); + ClassPathResource alipayCertResource = new ClassPathResource(aliConfig.getAlipayCertPath()); + ClassPathResource rootCertResource = new ClassPathResource(aliConfig.getAlipayRootCertPath()); + AlipayConfig config = new AlipayConfig(); // 设置网关地址 @@ -581,13 +586,13 @@ public class AliPayServiceImpl implements AliPayService { // 设置应用公钥证书路径(线上) // config.setAppCertPath(getClass().getResource("/cert/appCertPublicKey.crt").getPath()); // 设置应用公钥证书路径(沙箱) - config.setAppCertPath(ResourceUtils.getFile("classpath:" + aliConfig.getAppCertPath()).getAbsolutePath()); + config.setAppCertPath(appCertResource.getAbsolutePath()); // 设置支付宝公钥证书路径 - config.setAlipayPublicCertPath(ResourceUtils.getFile("classpath:" + aliConfig.getAlipayCertPath()).getAbsolutePath()); + config.setAlipayPublicCertPath(alipayCertResource.getAbsolutePath()); // 设置支付宝根证书路径 - config.setRootCertPath(ResourceUtils.getFile("classpath:" + aliConfig.getAlipayRootCertPath()).getAbsolutePath()); + config.setRootCertPath(rootCertResource.getAbsolutePath()); // 设置字符编码格式 config.setCharset("UTF-8");