17
17
18
18
import java .io .File ;
19
19
import java .io .FileOutputStream ;
20
+ import java .util .ArrayList ;
21
+ import java .util .Arrays ;
22
+ import java .util .LinkedList ;
20
23
import java .util .List ;
21
24
22
25
import static me .chanjar .weixin .cp .constant .WxCpApiPathConsts .MsgAudit .*;
@@ -39,20 +42,40 @@ public WxCpChatDatas getChatDatas(long seq, @NonNull long limit, String proxy, S
39
42
throw new WxErrorException ("请配置会话存档sdk文件的路径,不要配错了!!" );
40
43
}
41
44
45
+ /**
46
+ * 完整的文件库路径:
47
+ *
48
+ * /www/osfile/libcrypto-1_1-x64.dll,libssl-1_1-x64.dll,libcurl-x64.dll,WeWorkFinanceSdk.dll,libWeWorkFinanceSdk_Java.so
49
+ */
42
50
// 替换斜杠
43
51
String replacePath = configPath .replace ("\\ " , "/" );
44
- // 所有的后缀文件
45
- String suffixFiles = replacePath .substring (replacePath .lastIndexOf ("/" ) + 1 );
46
- // 获取的前缀路径
47
- String prefixPath = replacePath .substring (0 , replacePath .lastIndexOf ("/" ) + 1 );
52
+ // 获取最后一个斜杠的下标,用作分割路径
53
+ int lastIndex = replacePath .lastIndexOf ("/" ) + 1 ;
54
+ // 获取完整路径的前缀路径
55
+ String prefixPath = replacePath .substring (0 , lastIndex );
56
+ // 获取后缀的所有文件,目的遍历所有文件
57
+ String suffixFiles = replacePath .substring (lastIndex );
48
58
49
59
// 包含so文件
50
60
String [] libFiles = suffixFiles .split ("," );
51
61
if (libFiles .length <= 0 ) {
52
62
throw new WxErrorException ("请仔细配置会话存档文件路径!!" );
53
63
}
54
64
55
- Finance .loadingLibraries (libFiles , prefixPath );
65
+ List <String > libList = Arrays .asList (libFiles );
66
+ // 判断windows系统会话存档sdk中dll的加载,因为会互相依赖所以是有顺序的,否则会导致无法加载sdk #2598
67
+ List <String > osLib = new LinkedList ();
68
+ List <String > fileLib = new ArrayList ();
69
+ libList .stream ().forEach (s -> {
70
+ if (s .contains ("lib" )) {
71
+ osLib .add (s );
72
+ } else {
73
+ fileLib .add (s );
74
+ }
75
+ });
76
+ osLib .addAll (fileLib );
77
+
78
+ Finance .loadingLibraries (osLib , prefixPath );
56
79
long sdk = Finance .SingletonSDK ();
57
80
58
81
long ret = Finance .Init (sdk , cpService .getWxCpConfigStorage ().getCorpId (), cpService .getWxCpConfigStorage ().getCorpSecret ());
0 commit comments