我必须在我的项目中添加一个JNI模块。
我在Maven中安装模块作为两个不同的工件:jar库:
mvn install:install-file -DgroupId=com.test -DartifactId=ssa -Dversion=1.0 -Dpackaging=jar -Dfile=ssa.jar
和带有DLL的运行时库
mvn install:install-file -DgroupId=com.sirio -Dpackaging=ddl -DartifactId=ssa-runtime -classifier=windows-x86 -Dversion=1.0 -Dfile=SSADll.dll
在我的maven项目中,我添加了这些依赖项:
<dependency>
<groupId>com.test</groupId>
<artifactId>ssa</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.test</groupId>
<artifactId>ssa-runtime</artifactId>
<classifier>windows-${arch}</classifier>
<type>dll</type>
<version>1.0</version>
<scope>runtime</scope>
</dependency>
我的问题是当我运行shade插件目标来创建一个带有依赖项的jar时,我得到错误:
Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project ....: Error creating shaded jar: error in opening zip file sirio\ssa-runtime\1.0\ssa-runtime-1.0-windows-x86.dll
如何告诉shade插件不要解压缩dll?
这个解决方案适用于我的JavaFX-OpenCV项目
DLL
文件的情况下打包您的项目。DLL
文件复制并粘贴到jar文件目录中。DLL
文件现在都在您的jar应用程序的类路径中。你的目录应该是这样的: /target/application.jar /target/your_DLL_files.dll