Maven and native libraries

隐身守侯 提交于 2020-02-27 08:36:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!