[英]add external jar to our dependency
There is a jar file lets say "abc.jar" which maven dependency does not exist(ie created a jar by using java command of own classes). 有一个jar文件,可以说不存在maven依赖项的“ abc.jar”(即,使用自己的类的java命令创建了一个jar)。 I want to add this jar as maven dependency so that at build time it will automatically copy that jar in lib folder as like other maven dependency.
我想将此jar添加为maven依赖项,以便在构建时像其他其他maven依赖项一样自动将其复制到lib文件夹中。 how i will do.
我会怎么做。 please help .
请帮忙 。
Add it as a dependency with a system scope. 将其添加为具有系统范围的依赖项。 See the docs here .
在此处查看文档 。
However, rather than adding it as a system dependency it might be better to mavenize the jar itself, then you can build and install it into your dependency management system. 但是,与其将其添加为系统依赖项,不如将其本身进行修改,然后将其构建并安装到依赖项管理系统中,可能会更好。
Also, see this question: Can I add jars to maven 2 build classpath without installing them? 另外,请参见以下问题:是否可以在不安装jar的情况下将jar添加到maven 2 build classpath?
You can use the systemPath
attribute in the dependency
tag in the POM file of your project. 您可以在项目的POM文件中的
dependency
标记中使用systemPath
属性。
In your pom.xml, use the following snippet corresponding to abc.jar
: 在您的pom.xml中,使用与
abc.jar
相对应的以下代码段:
<dependencies>
<!-- Other dependencies -->
<dependency>
<groupId>abc</groupId>
<artifactId>x</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>{path_to_abc.jar}</systemPath>
</dependency>
</dependencies>
The scope
parameter corresponding to this artifact must be set to system
, for the artifact to be picked up from the specified systemPath
. 与该工件相对应的
scope
参数必须设置为system
,以便从指定的systemPath
获取工件。
Hope this helps! 希望这可以帮助!
A normal maven dependency is always resolved by looking into a repository. 通常,通过查看存储库可以解决常规的Maven依赖关系。 So you must put your JAR file into a repository.
因此,您必须将JAR文件放入存储库中。
You could install your JAR into your local repository. 您可以将 JAR 安装到本地存储库中。 Have a look at the install plugin .
看看安装插件 。 The install-file goal is your friend.
安装文件的目标是您的朋友。
If other developers also need this JAR (because they are working with the same project), they either need to install it locally too, or - better - you deploy the JAR to a remote repository. 如果其他开发人员也需要此JAR(因为他们正在同一个项目中工作),则他们也需要在本地安装它,或者-更好的是- 将 JAR 部署到远程存储库。 Have a look at the deploy plugin .
看一下deploy插件 。 Here the deploy-file goal is your friend.
在这里,部署文件目标就是您的朋友。 For deploying artifacts, you need a repository manager like Nexus or Artifactory .
要部署工件,您需要Nexus或Artifactory之类的存储库管理器。
However, a dependency could also have the system scope (look at the other answers). 但是,依赖项也可以具有系统范围(请参阅其他答案)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.