简体   繁体   English

如何将本地jar添加为maven项目的依赖项?

[英]how to add a local jar as a dependency to a maven project?

I am new to Maven and I want to add SSJ library to dependencies in a maven project, I tried adding this in the POM.xml: 我是Maven的新手,我想在一个maven项目中添加SSJ库到依赖项,我尝试在POM.xml中添加它:

  <dependency>
        <groupId>ca.umontreal.iro</groupId>
        <artifactId>ssj</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>

but eclipse is giving this error: Missing artifact ca.umontreal.iro:ssj-2.5 但是eclipse正在给出这个错误: Missing artifact ca.umontreal.iro:ssj-2.5

It seems that it's not found in the repository.. I have the jar file, how can I add it to dependencies? 它似乎没有在存储库中找到..我有jar文件,如何将其添加到依赖项? if possible. 如果可能的话。 If not, what would be the alternative to include this jar in the project? 如果没有,那么在项目中包含这个jar的替代方案是什么?

You'll need to add the jar to your maven local repository. 您需要将jar添加到maven本地存储库。

mvn install:install-file -Dfile=/path/to/ssj.jar -DgroupId=ca.umontreal.iro -DartifactId=ssj -Dversion=2.5 -Dpackaging=jar

(Change /path/to/ssj.jar to the path of the the file in your computer) (将/path/to/ssj.jar更改为计算机中文件的路径)

This will make it possible for Maven to resolve this JAR from the local repository using the dependency defined above, when you are building your application. 这将使Maven可以在构建应用程序时使用上面定义的依赖关系从本地存储库解析此JAR。

you can either install jar manually into local repository http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html or set the file storage path to dependency like 您可以手动将jar安装到本地存储库http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html,也可以将文件存储路径设置为依赖关系

<dependency>
    <groupId>com.3dpaty</groupId>
    <artifactId>abc</artifactId>
    <version>0.0.3</version>
        <systemPath>lib/3party.jar</systemPath>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM