2012-07-02 51 views
8

即時通訊使用Maven 3.0.4和Nexus 2.0.6。我已經設置了我的settings.xml作爲使用單個存儲庫的Nexus指令。 當maven試圖運行maven -U clean時,我得到下面的錯誤。Nexus不緩存maven中央插件

[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its d 
ependencies could not be resolved: Failed to read artifact descriptor for org.ap 
ache.maven.plugins:maven-clean-plugin:jar:2.4.1: Could not find artifact org.apa 
che.maven.plugins:maven-clean-plugin:pom:2.4.1 in nexus (http://localhost:8081/n 
exus/content/groups/public) -> [Help 1] 

如果我從設置中刪除nexus鏡像並直接轉到maven central,則該命令有效。 nexus中maven repo的設置表明它處於服務狀態,並且位於公共組(最後列出)中。

我並不支持訪問互聯網的代理。

這裏是我的settings.xml

<?xml version="1.0" encoding="UTF-8"?> 
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
<offline>false</offline> 
<mirrors> 
    <mirror> 
     <!--This sends everything else to /public --> 
     <id>nexus</id> 
     <mirrorOf>*</mirrorOf> 
     <url>http://localhost:8081/nexus/content/groups/public</url> 
    </mirror> 
</mirrors> 
<profiles> 
    <profile> 
     <id>nexus</id> 
     <!--Enable snapshots for the built in central repo to direct --> 
     <!--all requests to nexus via the mirror --> 
     <repositories> 
      <repository> 
       <id>central</id> 
       <url>http://central</url> 
       <releases><enabled>true</enabled></releases> 
       <snapshots><enabled>true</enabled></snapshots> 
      </repository> 
     </repositories> 
     <pluginRepositories> 
      <pluginRepository> 
       <id>central</id> 
       <url>http://central</url> 
       <releases><enabled>true</enabled></releases> 
       <snapshots><enabled>true</enabled></snapshots> 
      </pluginRepository> 
     </pluginRepositories> 
    </profile> 
    <profile> 
     <id>maven-central</id> 
     <!--Enable snapshots for the built in central repo to direct --> 
     <!--all requests to nexus via the mirror --> 
     <repositories> 
      <repository> 
       <id>central</id> 
       <url>http://repo1.maven.org/maven2/</url> 
       <releases><enabled>true</enabled></releases> 
       <snapshots><enabled>true</enabled></snapshots> 
      </repository> 
     </repositories> 
     <pluginRepositories> 
      <pluginRepository> 
       <id>central</id> 
       <url>http://repo1.maven.org/maven2/</url> 
       <releases><enabled>true</enabled></releases> 
       <snapshots><enabled>true</enabled></snapshots> 
      </pluginRepository> 
     </pluginRepositories> 
    </profile> 
</profiles> 
    <activeProfiles> 
    <!--make the profile active all the time --> 
    <activeProfile>nexus</activeProfile> 
</activeProfiles> 


</settings> 
+0

你能否檢查神器是否是通過網絡訪問它下載的 - http:// localhost:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/ – Raghuram

+0

您是否檢查過通過瀏覽器訪問Nexus並檢查是否可以通過瀏覽器訪問該工件? – khmarbaise

+0

我在這裏添加了更多類似情況的詳細信息:http://stackoverflow.com/questions/13927806/nexus-wont-download-artifacts-from-central/13928041#13928041 –

回答

3

嘗試直接通過Web瀏覽器下載此:

http://localhost:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom 

如果這不起作用檢查Sonatype的工作/關係/日誌/關係.log文件以獲取有關故障的更多信息。

5

確保Central代理存儲庫已正確配置,並且代理URL是http://repo1.maven.org/maven2/。檢查是否可以在存儲庫的URL中看到緩存的工件,應爲http://localhost:8081/nexus/content/repositories/central/org/apache/maven/plugins/maven-clean-plugin/2.4.0/maven-clean-plugin-2.4.1.pom

請確保您有一箇中央代理服務器,是否有任何東西列在http://localhost:8081/nexus/content/repositories/central/

如果你是一個代理之後,您可以配置默認HTTP代理服務器設置下的代理(可選)節中管理 - >的Nexus窗格。

然後,確保Public Repositories組存儲庫配置爲在其包含的存儲庫列表中包含Central存儲庫。

如果一切看起來都很好,請檢查日誌,也許這裏有一條有用的信息。

+0

確切地說,我還添加了官方Nexus文檔https://books.sonatype.com/nexus-book/3.0/reference/maven.html#maven-sect-single-group的鏈接,加上我自己的安裝說明帶有Nexus的Maven http://www.javamonamour.org/2017/09/nexus-and-maven-setup.html – PierluigiVernetto