Maven-java.library.path中的UnsatisfiedLinkError [英] Maven - UnsatisfiedLinkError with java.library.path

查看:82
本文介绍了Maven-java.library.path中的UnsatisfiedLinkError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使Maven加载本机库时遇到问题.当前,我将库文件(.so)放在src/main/resources/中,这给我一个错误,它在java.library.path中找不到.我也尝试将其放置在项目的基本目录中,但结果却相同.

I'm having a problem with trying to get Maven to load my native library. Currently, I placed my library file (.so) in src/main/resources/ and it gives me an error of it cannot be found in java.library.path. I also tried to place this in my base directory of the project, but gives me the same results.

下面是我尝试过的Maven插件,但它似乎不起作用.

Below is the maven plugin I tried, but it doesn't seem to work.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <systemProperties>
        <property>
          <name>java.library.path</name>
          <value>${project.build.directory}</value>
        </property>
      </systemProperties>
    </configuration>
  </plugin>

如果有帮助,我可以直接从Eclipse运行我的项目.我知道如何使其在Eclipse中工作,但希望它与maven一起工作.

If it helps, I run my project directly from Eclipse. I know how to get it to work in Eclipse but want it to work with maven.

@EDIT我也尝试在命令行上运行它,但仍然收到相同的错误

@EDIT I also tried running it on the command line and I still receive the same mistakes

推荐答案

我在项目中执行了以下操作:

I did the following in my project:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
        <argLine>-Djava.library.path=/path/to/your/libs:${java.library.path}</argLine>
        </configuration>
    </plugin>
</plugins>

它以这种方式为我工作.

And it worked for me that way.

这篇关于Maven-java.library.path中的UnsatisfiedLinkError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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