mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🎨 #2598 【企业微信】修复windows系统会话存档的加载顺序
This commit is contained in:
parent
f9cf8ca1de
commit
010c184caa
@ -2,6 +2,8 @@ package com.tencent.wework;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 注意:
|
||||
* 此类必须配置在com.tencent.wework路径底下,否则会报错:
|
||||
@ -147,7 +149,7 @@ public class Finance {
|
||||
* @param libFiles 类库配置文件
|
||||
* @param prefixPath 类库文件的前缀路径
|
||||
*/
|
||||
public Finance(String[] libFiles, String prefixPath) {
|
||||
public Finance(List<String> libFiles, String prefixPath) {
|
||||
boolean isWindows = Finance.isWindows();
|
||||
for (String file : libFiles) {
|
||||
String suffix = file.substring(file.lastIndexOf(".") + 1);
|
||||
@ -173,7 +175,7 @@ public class Finance {
|
||||
* @param prefixPath
|
||||
* @return
|
||||
*/
|
||||
public synchronized static Finance loadingLibraries(String[] libFiles, String prefixPath) {
|
||||
public synchronized static Finance loadingLibraries(List<String> libFiles, String prefixPath) {
|
||||
if (finance != null) {
|
||||
return finance;
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.MsgAudit.*;
|
||||
@ -39,12 +42,19 @@ public class WxCpMsgAuditServiceImpl implements WxCpMsgAuditService {
|
||||
throw new WxErrorException("请配置会话存档sdk文件的路径,不要配错了!!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 完整的文件库路径:
|
||||
*
|
||||
* /www/osfile/libcrypto-1_1-x64.dll,libssl-1_1-x64.dll,libcurl-x64.dll,WeWorkFinanceSdk.dll,libWeWorkFinanceSdk_Java.so
|
||||
*/
|
||||
// 替换斜杠
|
||||
String replacePath = configPath.replace("\\", "/");
|
||||
// 所有的后缀文件
|
||||
String suffixFiles = replacePath.substring(replacePath.lastIndexOf("/") + 1);
|
||||
// 获取的前缀路径
|
||||
String prefixPath = replacePath.substring(0, replacePath.lastIndexOf("/") + 1);
|
||||
// 获取最后一个斜杠的下标,用作分割路径
|
||||
int lastIndex = replacePath.lastIndexOf("/") + 1;
|
||||
// 获取完整路径的前缀路径
|
||||
String prefixPath = replacePath.substring(0, lastIndex);
|
||||
// 获取后缀的所有文件,目的遍历所有文件
|
||||
String suffixFiles = replacePath.substring(lastIndex);
|
||||
|
||||
// 包含so文件
|
||||
String[] libFiles = suffixFiles.split(",");
|
||||
@ -52,7 +62,20 @@ public class WxCpMsgAuditServiceImpl implements WxCpMsgAuditService {
|
||||
throw new WxErrorException("请仔细配置会话存档文件路径!!");
|
||||
}
|
||||
|
||||
Finance.loadingLibraries(libFiles, prefixPath);
|
||||
List<String> libList = Arrays.asList(libFiles);
|
||||
// 判断windows系统会话存档sdk中dll的加载,因为会互相依赖所以是有顺序的,否则会导致无法加载sdk #2598
|
||||
List<String> osLib = new LinkedList();
|
||||
List<String> fileLib = new ArrayList();
|
||||
libList.stream().forEach(s -> {
|
||||
if (s.contains("lib")) {
|
||||
osLib.add(s);
|
||||
} else {
|
||||
fileLib.add(s);
|
||||
}
|
||||
});
|
||||
osLib.addAll(fileLib);
|
||||
|
||||
Finance.loadingLibraries(osLib, prefixPath);
|
||||
long sdk = Finance.SingletonSDK();
|
||||
|
||||
long ret = Finance.Init(sdk, cpService.getWxCpConfigStorage().getCorpId(), cpService.getWxCpConfigStorage().getCorpSecret());
|
||||
|
Loading…
Reference in New Issue
Block a user