Maven找不到本地安装的软件包

时间:2018-12-15 23:54:58

标签: java maven

我正在尝试在我的项目(特别是Z3)中使用第三方jar。 第三部分jar不是用mvn构建的,因此我使用以下命令将其添加:

mvn install:install-file                        \                                                   
    -Dfile="$z3_build_dir"/com.microsoft.z3.jar \                                                   
    -DgroupId=com.microsoft                     \                                                   
    -DartifactId=z3                             \                                                   
    -Dversion=1.0.0                             \                                                   
    -Dpackaging=jar                             \                                                   
    -DgeneratePom=true                                                                              

我已将依赖项添加到项目的pom文件中:

<dependency>
  <groupId>org.microsoft</groupId>
  <artifactId>z3</artifactId>
  <version>1.0.0</version>
</dependency>

我可以在~/.m2/repository/com/microsoft/z3/1.0.0/z3-1.0.0.pom处看到已安装的文件。

但是,我看到此警告和错误:

Downloading from central: https://repo.maven.apache.org/maven2/org/microsoft/z3/1.0.0/z3-1.0.0.pom
Downloading from other-repo: https://other-repo/repository/internal/org/microsoft/z3/1.0.0/z3-1.0.0.pom
[WARNING] The POM for org.microsoft:z3:jar:1.0.0 is missing, no dependency information available
Downloading from central: https://repo.maven.apache.org/maven2/org/microsoft/z3/1.0.0/z3-1.0.0.jar
Downloading from other-repo: https://other-repo/repository/internal/org/microsoft/z3/1.0.0/z3-1.0.0.jar
...
[ERROR] Failed to execute goal on project java-backend: Could not resolve [redacted] Could not find artifact org.microsoft:z3:jar:1.0.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

Maven文档说,我无需执行任何其他操作即可找到本地安装的软件包,因此我不明白为什么它要搜索Central。

2 个答案:

答案 0 :(得分:4)

groupId必须匹配。更改

<groupId>org.microsoft</groupId>

<groupId>com.microsoft</groupId>

就像您在此处指定的那样:

mvn install:install-file                        \                                                   
    -Dfile="$z3_build_dir"/com.microsoft.z3.jar \                                                   
    -DgroupId=com.microsoft                     \                                                   
    -DartifactId=z3                             \                                                   
    -Dversion=1.0.0                             \                                                   
    -Dpackaging=jar                             \                                                   
    -DgeneratePom=true*   

答案 1 :(得分:2)

pom输入错误。应该是(根据您的安装命令)

<dependency>
  <groupId>com.microsoft</groupId>
  <artifactId>z3</artifactId>
  <version>1.0.0</version>
</dependency>
相关问题