繁体   English   中英

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

[英]Maven fails to get SNAPSHOT builds from repository

我们的内部存储库(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,

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

任何有关这个问题的见解将不胜感激。

编辑

使用-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)

想到两个想法:

  1. 内部存储库中用于工件的路径结构不正确。 我建议使用-X参数运行maven命令。 它将显示maven尝试下载文件。 获取将您的存储库作为URL的行,并尝试自己查找。

    路径应该是这样的

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

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

通常,您有来自版本URL的单独快照URL。 只是在同一个存储库中的不同路径,但在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>

暂无
暂无

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

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