将dependecy添加到Maven并设置为$ CATALINA_HOME/shared/lib [英] Add dependecy to Maven and set to $CATALINA_HOME/shared/lib
问题描述
我在Web项目中使用Matlab MCR,所以我将这些依赖项导入pom.xml
I'm using Matlab MCR in web project so I imported these dependecies to pom.xml
<!-- Matlab client tool library -->
<!-- <dependency>
<groupId>DataConcatenation</groupId>
<artifactId>DataConcatenation</artifactId>
<version>0.0.5-SNAPSHOT</version>
</dependency> -->
<!-- <dependency>
<groupId>DataConcatenator</groupId>
<artifactId>DataConcatenator</artifactId>
<version>0.0.5-SNAPSHOT</version>
</dependency> -->
<!-- <dependency>
<groupId>DataConversion</groupId>
<artifactId>DataConversion</artifactId>
<version>0.0.5-SNAPSHOT</version>
</dependency> -->
<dependency>
<groupId>DataConverter</groupId>
<artifactId>DataConverter</artifactId>
<version>0.0.5-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>DataConcatenation</artifactId>
<groupId>DataConcatenation</groupId>
</exclusion>
<exclusion>
<artifactId>DataConcatenator</artifactId>
<groupId>DataConcatenator</groupId>
</exclusion>
<exclusion>
<artifactId>DataConversion</artifactId>
<groupId>DataConversion</groupId>
</exclusion>
</exclusions>
</dependency>
第一个问题是,即使我仅使用DataConverter,我也必须排除其他树相关性,但是我只需要dataConverter,并且此库没有其他依赖项. 第二个也是最重要的问题是此错误:
The first problems is that I have to exclude the other tree dependencies even if I use only DataConverter, But I need only dataConverter and this library doesn't have other dependecies. The second and most important problem is this error:
Threw exception in ZipAndMat::createZipAndMat: java.lang.UnsatisfiedLinkError: Native Library /usr/v81/bin/glnxa64/libnativedl.so already loaded in another classloader
我阅读了很多指南,并且我了解我必须将这个jar放入$ CATALINA_HOME/shared/lib中,以便所有类加载器共享同一个jar. 但是,如何在上面的路径中添加这种依赖呢?这是我第一次实现此配置.我在服务器上使用tomcat并通过war文件部署项目. 谢谢
I read a lot of guide and I understand that I have to put this jar into $CATALINA_HOME/shared/lib so all the class loader share the same jar. But how can I add this dependecy to the above path? This is the first time that I have to implement this configuration. I use tomcat on my server and deploy project through war file. Thanks
推荐答案
您可以将罐子放入$CATALINA_HOME/shared/lib
,然后在
You can place the jar into $CATALINA_HOME/shared/lib
, and then specify in your POM the dependency's <scope>
as provided
:
<dependency>
<groupId>DataConverter</groupId>
<artifactId>DataConverter</artifactId>
<version>0.0.5-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
...
</exclusions>
</dependency>
此方法通常用于在Tomcat上运行时包含 JDBC驱动程序的jar;将jdbc jar放在$CATALINA_HOME/shared/lib
中(因此所有 WAR 都可以找到它) ),但每个项目列表都将JDBC jar作为依赖项,并以provided
作为范围.
This method is often used for jars which contain JDBC drivers when running on Tomcat; the jdbc jar is placed in $CATALINA_HOME/shared/lib
(so all WARs can find it), yet each project list’s the JDBC jar as a dependency with provided
as the scope.
有关更多信息,请参见这篇文章 provided
上的信息.
See this post for more information on provided
.
这篇关于将dependecy添加到Maven并设置为$ CATALINA_HOME/shared/lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!