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

Sam*_*ami 4 java dependencies maven-3

我是 Maven 新手,我想将SSJ库添加到 Maven 项目中的依赖项中,我尝试在 POM.xml 中添加以下内容:

  <dependency>
        <groupId>ca.umontreal.iro</groupId>
        <artifactId>ssj</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

但 eclipse 给出了这个错误:Missing artifact ca.umontreal.iro:ssj-2.5

似乎在存储库中找不到它。我有 jar 文件,如何将其添加到依赖项中?如果可能的话。如果没有,将这个 jar 包含在项目中的替代方案是什么?

And*_*sov 6

您可以手动将 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>
    <scope>system</scope>
    <systemPath>lib/3party.jar</systemPath>
</dependency>
Run Code Online (Sandbox Code Playgroud)


Raj*_*ani 5

您需要将 jar 添加到您的 Maven 本地存储库。

mvn install:install-file -Dfile=/path/to/ssj.jar -DgroupId=ca.umontreal.iro -DartifactId=ssj -Dversion=2.5 -Dpackaging=jar
Run Code Online (Sandbox Code Playgroud)

(将/path/to/ssj.jar更改为该文件在您计算机中的路径)

这将使 Maven 在构建应用程序时能够使用上面定义的依赖项从本地存储库解析此 JAR。