[英]Maven and native libraries
I use maven in my java project, and I don't understand how to add in native libraries. 我在我的java项目中使用maven,我不明白如何添加本机库。 In my non-maven project I did it via CLASSPATH. 在我的非maven项目中,我是通过CLASSPATH完成的。 I use NetBeans and maven in my current java project. 我在当前的java项目中使用NetBeans和maven。
If you just want to add the native libraries to the class path, try to put them in src/main/resources
. 如果您只想将本机库添加到类路径中,请尝试将它们放在src/main/resources
。
Update: You can specify where resources exist in the POM: 更新:您可以指定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>
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,您应该采用Maven的标准布局 (或者您必须为自定义布局配置每个插件,这更多是问题的根源而不是好处)。
you can define your native lib like this way 你可以这样定义你的本机库
<dependency>
<groupId>com.***.</groupId>
<artifactId>abc.jar</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/abc.jar</systemPath>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.