问题描述
我需要在我的maven项目中添加大约15个罐子,并且它在远程和中央存储库中都不可用。
I need to add some 15 jars in my maven project , and it is not available in both remote and central repository.
然而,我已经实现了如下,
however, i have achieved it as below,
- 添加了罐子里面我的项目路径(\src\lib)
-
更改了pom,如下所示,
- added the jars in my project path(\src\lib)
changed the pom as below,
<dependency>
<groupId>XXX</groupId>
<artifactId>YYY</artifactId>
<scope>system</scope>
<version>8.1</version>
<systemPath>${basedir}\src\lib\YYY.jar</systemPath>
</dependency>
我的问题:
我是否需要像上面那样分别重复所有15个罐子,或者我们有任何其他方法来绑定这些罐子并将其作为一个依赖路径?
Do i need to repeat it for all the 15 jars separatly as the above or we have any other way to bind these jars and make it as one dependency path?
这里讨论的内容相同。但我想知道我是否可以获得更好/新想法,因为这是5年的讨论
The same thing discussed here Maven: System dependency pointing to multiple jars . but i wonder if i could get anything better/new ideas , since it is 5 years old discussion
Maven版本: 3.3.9
推荐答案
我认为你永远不应该使用systemPath
I think you should never use systemPath
相反,考虑安装罐子进入您的本地存储库,如下所述:
Instead, consider installing the jars into your local repository like explained here: https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
Maven允许您在存储库中添加库手动调用:
Maven let you add a library in your repository by calling manually:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
这样做,您的罐子将安装在.m2存储库中,并可作为其他依赖项使用你的模块
Doing that, your jars will be installed in your .m2 repository and will be available as other dependencies in your module
编辑:
我们可以补充一点,当与同伴一起工作时,我们通常使用我们自己的存储库管理器,如Nexus()或Artifactory()
We can add that when working with teamates, we usually use our own repository manager like Nexus (http://www.sonatype.org/nexus/) or Artifactory (https://www.jfrog.com/open-source/)
这篇关于Maven外部依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!