2017-04-13 164 views
0

我有一個Maven工件存儲在Artifactory上的受保護的存儲庫中。我有我的用戶憑證設置在settings.xml。同時我配置Artifactory的方式是允許匿名訪問某些公共存儲庫。Artifactory:Maven發現的文件,如果允許匿名訪問

當我現在嘗試下載使用Maven的神器,我收到以下錯誤信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:get (default-cli) 
    on project artifactory: Couldn't download artifact: Could not find artifact 
    XXX:common:jar:2.2.1-RELEASE in artifactory-XXX (http://XXX/artifactory/XXX) 

當我禁用Artifactory的匿名訪問,一切正常。

因此,看起來Maven在Artifactory服務器的公共倉庫找不到它所提供的用戶憑證後,無法搜索該工件。

我是否缺少一些Artifactory配置,或者不能在同一臺服務器上同時擁有公共和受保護的存儲庫?

回答

1

您是否可以檢查Artifactory用戶界面 - >管理 - >安全配置 - >如果選中「隱藏未授權資源的存在」複選框?

如果是這樣可以解釋問題。當檢查到這一點時,Artifactory將不會顯示非授權用戶的工件並返回404。如果確實是這個問題,您可以設置maven to use a preemptive authentication以便從第一個請求進行認證。下面是配置在.m2/settings.xml搶先認證片段:

<server> 
    <id>artifactory</id> 
    <configuration> 
    <httpConfiguration> 
     <all> 
     <usePreemptive>true</usePreemptive> 
     </all> 
    </httpConfiguration> 
    </configuration> 
    <username>...</username> 
    <password>...</password> 
</server> 

如果這是不是你在artifactory.logrequest.log看到Artifactory的得到這個失敗的消息後,這個問題?

+1

嗨@Ariel,感謝您的回答 - 確實解決了我的問題。我在你的文章中添加了一段代碼,並鏈接了Maven文檔。 –

+0

謝謝邁克爾,我已批准編輯。謝謝你。 – Ariel

相關問題