问题描述
我在我的java项目中使用maven,我不明白如何添加本机库。在我的非maven项目中,我是通过CLASSPATH完成的。我在当前的java项目中使用NetBeans和maven。
I use maven in my java project, and I don't understand how to add in native libraries. In my non-maven project I did it via CLASSPATH. I use NetBeans and maven in my current java project.
推荐答案
如果您只想将本机库添加到类路径中,尝试将它们放入 src / main / resources
。
If you just want to add the native libraries to the class path, try to put them in src/main/resources
.
更新:你可以指定POM中的位置:
Update: You can specify where resources exist in the POM:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<build>
...
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/native</directory>
<includes>
<include>native.so</include>
</includes>
</resource>
</resources>
<testResources>
...
</testResources>
...
</build>
</project>
但老实说,如果你决定使用Maven,你应该采用Maven的(或者您必须为每个插件配置您的自定义布局,这是问题的根源,而不是好处)。
But honestly, if you decide to use Maven, you should adopt Maven's standard layout (or you'll have to configure every plugin for your custom layout which is more a source of problems than benefits).
这篇关于Maven和本地图书馆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!