2012-07-02 243 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