Maven无法从存储库获取SNAPSHOT构建

时间:2010-11-04 14:05:25

标签: java maven-2 artifactory

我们的内部存储库(Artifactory)现在包含稳定版本以及内部库的SNAPSHOT版本。

对于稳定版本,从存储库中下载任何内容从未出现过问题。

然而,当我添加一个-SNAPSHOT时,Maven声称无法找到依赖项,即使它绝对存放在存储库中。

如果我在本地构建和部署依赖项(即进入我的本地仓库),一切正常。

基本上,这有效:

<dependency>
  <groupId>com.example</groupId>
  <artifactId>ourlibrary</artifactId>
  <version>1.0.0</version>
</dependency>

而这不是:

<dependency>
  <groupId>com.example</groupId>
  <artifactId>ourlibrary</artifactId>
  <version>1.0.1-SNAPSHOT</version>
</dependency>

尽管两个版本都是以相同的方式构建的,并且(正如我可能知道的那样)正确地部署到存储库。

错误:

Missing:
----------

1) com.example:ourlibrary:jar:1.0.1-SNAPSHOT,

  Try downloading the file manually from the project website.

  Then, install it using the command:
      mvn install:install-file -DgroupId=com.example -DartifactId=ourlibrary -Dversion=1.0.1-SNAPSHOT, -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there:
      mvn deploy:deploy-file -DgroupId=com.example -DartifactId=ourlibrary -Dversion=1.0.1-SNAPSHOT, -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency:
        1) com.example:product:war:2.0.0-SNAPSHOT
        2) com.example:ourlibrary:jar:1.0.1-SNAPSHOT,

虽然这听起来与this问题相似,但到达那里的决议并不适用于我的情况。

对此问题的任何见解将不胜感激。

修改

使用-X运行(如John V.所建议)显示以下内容:

[DEBUG] Skipping disabled repository central
[DEBUG] ourlibrary: using locally installed snapshot
[DEBUG] Skipping disabled repository central
[DEBUG] Using mirror: http://repo.example.com/repo (id: repo.example.com)
[DEBUG] Artifact not found - using stub model: Unable to download the artifact from any repository

  com.example:ourlibrary:pom:1.0.1-SNAPSHOT

from the specified remote repositories:
  repo.example.com (http://repo.example.com/repo)


[DEBUG] Using defaults for missing POM com.example:ourlibrary:pom:1.0.1-SNAPSHOT:compile
[DEBUG]   com.example:ourlibrary:jar:1.0.1-SNAPSHOT:compile (selected for compile)

2 个答案:

答案 0 :(得分:14)

想到两个想法:

  1. 内部的路径结构 你的工件的存储库是 不正确。我建议运行 使用-X参数的maven命令。它 将显示maven的尝试 下载文件。得到这条线 将您的存储库作为URL 并尝试自己寻找。

    路径应该看起来像

    /com/example/ourlibrary/1.0.1/ourlibrary-1.0.1-SNAPSHOT.jar

  2. 您没有将您的存储库包含为 pom.xml中的存储库

答案 1 :(得分:13)

通常,您有来自版本网址的单独快照网址。只是在同一个存储库中的不同路径,但在pom中列为单独的存储库。快照之一需要启用快照,而版本快照则禁用快照:

<repositories>
        <repository>
            <id>central</id>
            <url>
                http://<releases-url>
            </url>
            **<snapshots>
                <enabled>false</enabled>
            </snapshots>**
        </repository>

        <repository>
            <id>snapshots</id>
            <url>
                http://<snapshots-url>
            </url>
            <snapshots>
                **<enabled>true</enabled>**
                <!-- never, daily, interval:X (where X is in minutes) or always -->
                <!--<updatePolicy>daily</updatePolicy> -->
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>