Nexus和Maven:访问Maven Central Repo?

时间:2013-04-22 08:40:10

标签: maven continuous-integration nexus

使用Nexus和Maven时遇到了一些麻烦。 当我尝试使用Nexus使用Maven构建项目时,Maven无法找到任何工件。我将此添加到Maven设置:

     <mirror>
       <id>nexus</id>
       <url>http://localhost:6060/nexus/content/groups/public</url>
       <mirrorOf>central</mirrorOf>
     </mirror>

将Maven与Nexus连接起来。 Maven中央仓库也在Nexus设置中定义

2 个答案:

答案 0 :(得分:1)

您可以尝试这样:

<mirror>
    <id>nexus-local</id>
    <url>http://localhost:6060/nexus/content/groups/public/</url>
    <mirrorOf>external:*</mirrorOf>
</mirror>

答案 1 :(得分:1)

根据Nexus的文档,您应该配置settings.xml文件,如下所示:

最重要的是 mirrorOf 只包含一个asterik,可以将所有请求重定向到配置的Nexus实例。

<settings>
  <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>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>