Nexus和Maven构建

时间:2016-05-31 08:19:48

标签: maven nexus

我已经安装并配置了Nexus3。它位于代理服务器后面,并配置了HTTP部分。

[第一评论后更新]

在我的settings.xml上

<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">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <proxies/>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://nexus.company.it:8081/repository/maven-central/</url>
    </mirror>
  </mirrors> 
</settings>

当我尝试运行mvn clean时,我得到了

 [INFO] Scanning for projects...
 [INFO]                                                                         
 [INFO] ------------------------------------------------------------------------
 [INFO] Building xxxx Maven Webapp 0.0.1-SNAPSHOT
 [INFO] ------------------------------------------------------------------------
 [WARNING] The POM for org.apache.maven.plugins:maven-clean-plugin:jar:2.5 is missing, no dependency information available
 [INFO] ------------------------------------------------------------------------
 [INFO] BUILD FAILURE
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time: 0.205 s
 [INFO] Finished at: 2016-05-31T10:40:58+02:00
 [INFO] Final Memory: 13M/479M
 [INFO] ------------------------------------------------------------------------
 [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-clean-plugin:jar:2.5 in http://nexus.company.it:8081/repository/maven-central/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
 [ERROR] 
 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
 [ERROR] 
 [ERROR] For more information about the errors and possible solutions, please read the following articles:
 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

如果我浏览http://nexus.company.it:8081/repository/maven-central/

 Nexus Repository Manager
 OSS 3.0.0-03    
 This maven2 proxy repository is not directly browseable at this URL.

如果我浏览http://nexus.company.it:8081/#browse/browse/components:maven-central,则存储库为空

有人可以帮我配置我的nexus作为maven central的代理吗?

[R

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,即使&#34; mvn clean -U&#34;仍然无法正常工作。也许有人可以指出我正确的解决方案

1)插件不在中心位置。你应该maven-public将maven-central和maven-releases / snapshots分组

2)我在Nexus3中禁用了匿名登录。所以我需要创建一个用户来连接到Nexus3。这里有最终的settings.xml

<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">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <profiles/>
  <proxies>
      <proxy>
        <active>true</active>
        <protocol>http</protocol>
        <host>XXX.XXX.XXX.XXX</host>
        <port>XXX</port>
        <nonProxyHosts>XXX.XXX.*|*localhost*|*.company.it*</nonProxyHosts>
      </proxy>
  </proxies>
  <servers>
     <server>
       <id>nexus</id>
       <username>XXXXXXXXXX</username>
       <password>XXXXXXXXXX</password>
     </server>
  </servers>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://nexus.company.it:8081/repository/maven-public/</url>
    </mirror>
  </mirrors> 
  <activeProfiles/>
</settings>

3)当您使用mvn

时添加-U选项

的Riccardo