问题
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.
回答1:
If you just want to add the native libraries to the class path, try to put them in src/main/resources
.
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>
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).
回答2:
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>
来源:https://stackoverflow.com/questions/2448351/maven-and-native-libraries