maven-surefire-plugin、DLL 和 java.library.path [英] maven-surefire-plugin, DLLs and java.library.path
问题描述
我有一个在运行时需要 DLL 的 Maven 依赖项.我想要做的只是将该 dll 放在 resources/lib
文件夹中,并将其 DLL 放到 target
目录中.所以我所做的是:
I have a Maven dependency that requires a DLL at runtime. What I want to do is to simply have that dll in resources/lib
folder and place its DLLs to the target
directory. So what've I done is :
- 将 DLL 添加到
src/main/resources/lib
修改
pom.xml
以使用参数 -Djava.library.path=${basedir}/lib 像这样:
- Added DLLs to
src/main/resources/lib
Modified
pom.xml
to use argument -Djava.library.path=${basedir}/lib like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<workingDirectory>target</workingDirectory>
<argLine>-Djava.library.path=${basedir}/lib</argLine>
</configuration>
</plugin>
但是我仍然收到运行时错误,即 java.library.path 中不存在 DLL.
However I am still getting runtime error that DLL is not present in java.library.path.
推荐答案
您的
指向了错误的路径.试试这个:
Your <argLine/>
points to an incorrect path. Try this instead:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<workingDirectory>target</workingDirectory>
<argLine>-Djava.library.path=${basedir}/src/main/resources/lib</argLine>
</configuration>
</plugin>
如果此 DLL 仅用于测试,则应将其放在 src/test/resources
下.在这种情况下,
路径将更改为 ${project.build.directory}/test-classes
.
If this DLL will only be used for tests, you should put it under src/test/resources
. In that case the <argLine/>
path will change to ${project.build.directory}/test-classes
.
这篇关于maven-surefire-plugin、DLL 和 java.library.path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!