13

多年来,我一直在复制“示例”settings.xml文件,几乎所有这些文件似乎都包含一个带有 URL 的存储库http://central。这让我很烦,因为在本地域中实际上可能有一台名为“central”的机器,所以这是一个有效的 URN,但它也必须(可能?)对 Maven 有一些特殊的含义。

它只是常用的简写,但实际的 URL 被忽略了吗?我可以用其他东西替换它,还是完全删除它?它在任何地方都有记录吗?

如果重要的话,我会在具有内部 iBiblio 镜像的企业网络上开发,它充当我们的“中心”。

4

2 回答 2

21

AFAIK,它在Configure Maven to Download from Nexusa bogus URL中提到如下示例:-

<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>

nexus profile配置central repository为从下载a bogus URLhttp://central

此 URL同一settings.xml文件中的镜像设置覆盖,以指向您的single Nexus group. 然后,nexus 组在 activeProfiles 元素中列为活动配置文件。

我希望这可能会有所帮助。

于 2013-04-23T09:25:15.237 回答
2

我们也完全使用了这个示例配置,即使使用相同的评论大约 15(!)年也没有任何问题。对于 maven 构建,这并不重要,因为任何依赖项都需要 nexus。

但是今天我尝试使用组合的 ant+maven 构建构建一个项目,该构建未能通过来自中央仓库的 artifact:remoteRepository 任务获取依赖项。

解决方案是修复中央仓库中的“url”标签:https ://repo.maven.apache.org/maven2

所以看起来在大多数情况下它并不重要,但为了避免任何极端情况,请始终使用正确的 url。

于 2018-07-05T13:16:09.410 回答