簡體   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