我的方法:
使用特定于平台的分类器将文件放入存储库,如下所示:.为所有必需的平台添加依赖项:.so
sqlite3-3.7.9-linux-x86_64.so
.so
<dependency>
<groupId>de.ch-werner</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.7.9</version>
<type>so</type>
<classifier>linux-x86_64</classifier>
</dependency>
使用此 maven 程序集插件配置将所有本机库放入 dist 的目录中:lib/native
<dependencySet>
<outputDirectory>lib/native</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<unpack>false</unpack>
<useProjectArtifact>false</useProjectArtifact>
<useStrictFiltering>false</useStrictFiltering>
<includes>
<include>*:*:dll:*</include>
<include>*:*:so:*</include>
<include>*:*:jnilib:*</include>
</includes>
</dependencySet>
使用此类在应用程序启动时加载库(计划将分类器命名更改为 GNU 三元组):
CtzJniUtils.loadJniLibsFromStandardPath(Launcher.class, "sqlite3")