将企业微信提供的linux和windows的sdk文件解压,将里面的dll、so、java文件放到src/main/java目录下,如下图所示
参考https://zhuanlan.zhihu.com/p/37686736x修改pom文件将dll和so文件打包进jar
然后更改Finance的static代码块:
static {
if (isWindows()) {
String path = Finance.class.getResource("").getPath().replaceAll("%20", " ").replaceFirst("/", "").replace("/", "\\\\");
//加载顺序不要变
System.load(path.concat("libeay32.dll"));
System.load(path.concat("libprotobuf.dll"));
System.load(path.concat("ssleay32.dll"));
System.load(path.concat("libcurl.dll"));
System.load(path.concat("WeWorkFinanceSdk.dll"));
} else {
String path = Finance.class.getResource("").getPath();
System.load(path.concat("libWeWorkFinanceSdk_Java.so"));
}
}
public static boolean isWindows() {
String osName = System.getProperties().getProperty("os.name");
System.out.println("current system is " + osName);
return osName.toUpperCase().indexOf("WINDOWS") != -1;
}
大佬有没有遇到过在本地调是通的,发布后就报网络问题?
楼主这样配置 linux 环境下报错
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.dll</include>
<include>**/*.so</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
docker 镜像如果使用from tomcat:9.0.13-jre8-alpine这种alpine版本的话,还是会报ld-linux.so.2 (No such file or directory)异常,最好使用from tomcat:9.0.13这种非阉割版本的linux