没有搜索maven的多个存储库

时间:2015-09-01 09:37:47

标签: maven nexus

在我的settings.xml中,我已经配置了这个 -

<mirrors>
     <mirror>
                        <id>lon33881xus</id>
                        <name>Project Nexus Repo</name>
                        <url>http://lonrs08358:9093/nexus/content/groups/public</url>
                        <mirrorOf>central,maven2-repository.dev.java.net,thirdparty1</mirrorOf>
                </mirror>

        <mirror>
            <id>lon80813</id>
            <mirrorOf>*</mirrorOf>                <url>http://lon3388x1us:1083/nexus/content/groups/public</url>
                </mirror>
                 <mirror>
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://lonrs03296:1081/nexus/content/repositories/riskit_common_snapshot/</url>
        </mirror>
<!--<mirror>
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://m2.neo4j.org/content/repositories/releases/</url>
                </mirror> -->
    </mirrors>

但是当maven构建运行时,只有第一个存储库被装入jar中,然后构建失败,因为它无法找到第二个存储库中存在的jar。我希望在第一个回购中搜索罐子,如果没有找到则在第二个回复。我是maven的新手,请帮助。

1 个答案:

答案 0 :(得分:0)

此处的最佳选择是配置您的本地关联以使用http://m2.neo4j.org/content/repositories/releases。将此网站添加为nexus proxy

然后你的配置应该是这样的:

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://lonrs08358:9093/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>

之后,所有动作都在幕后完成。如果您的本地关系没有库,它将从代理下载,然后您也应该在本地仓库中收到该库。