Слияние кода завершено, страница обновится автоматически
ClassPathResource classPathResource = new ClassPathResource("cer/weixinPay/apiclient_cert.p12");
WeChatPayConfigurator weChatPayConfigurator = new WeChatPayConfigurator();
weChatPayConfigurator.setAppId(appId);
weChatPayConfigurator.setMchId(mchId);
weChatPayConfigurator.setMchKey(mchKey);
weChatPayConfigurator.setCertificatePath(classPathResource.getAbsolutePath());
weChatPayConfigurator.setPaymentNotifyUrl(notifyUrl);
В idea запуск проходит без проблем, но при запуске на сервере в виде jar-файла возникает ошибка:
Caused by: java.io.FileNotFoundException: /mall-portal-1.0-SNAPSHOT.jar!/BOOT-INF/classes!/cer/weixinPay/apiclient_cert.p12 (No such file or directory)
mall-portal | at java.io.FileInputStream.open0(Native Method) ~[na:1.8.0_111]
mall-portal | at java.io.FileInputStream.open(FileInputStream.java:195) ~[na:1.8.0_111]
mall-portal | at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[na:1.8.0_111]
mall-portal | at java.io.FileInputStream.<init>(FileInputStream.java:93) ~[na:1.8.0_111]
mall-portal | at cn.javaer.wechat.pay.client.HttpClientFactory.build(HttpClientFactory.java:55) ~[wechat-pay-1.1.0.jar!/:na]
Похоже, что при запуске в виде jar-файла невозможно прочитать файл из ресурса по пути. См.: https://stackoverflow.com/questions/25869428/classpath-resource-not-found-when-running-as-jar
Есть ли другие способы передачи сертификата?