maven-surefire-plugin、DLL 和 java.library.path [英] maven-surefire-plugin, DLLs and java.library.path

查看:106
本文介绍了maven-surefire-plugin、DLL 和 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 :

  1. 将 DLL 添加到 src/main/resources/lib
  2. 修改 pom.xml 以使用参数 -Djava.library.path=${basedir}/lib 像这样:

  1. Added DLLs to src/main/resources/lib
  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆