我的Maven settings.xml中的"http://central"是什么意思?

14

我已经复制了“示例”settings.xml文件很长一段时间了,几乎所有这样的文件似乎都包含一个具有URL http://central的存储库。这让我很烦恼 ,因为当然可以在本地域上存在名为“central”的计算机,因此这是一个有效的URN,但它也必须(可能?)对Maven有某些特殊含义。

这只是常用的速记符号,实际的URL被忽略了吗?我能否替换它或完全删除它?是否有文档记录了它?

如果要紧要的话,我在一个具有内部iBiblio镜像的企业网络上进行开发,该镜像作为我们的“中央”。

2个回答

23

据我所知,a bogus URL是一个虚假的网址,在配置Maven从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>

nexus profile 被配置为使用虚假的URL http://central中央仓库 下载。

这个URL在同一个 settings.xml 文件中被 镜像设置覆盖,指向您的单个 Nexus 组 的URL。然后将Nexus组列为活动配置文件的活动Profiles元素中。

希望这可以帮助到您。


3
我们曾经使用过这个样本配置,甚至连注释都一样,已经使用了15年(!),没有任何问题。对于maven构建来说,这并不重要,因为任何依赖都需要请求nexus。
但是今天我尝试使用组合的ant+maven构建项目,结果通过artifact:remoteRepository任务从中央仓库获取依赖项失败。
解决方案是修复中央仓库中"url"标签:https://repo.maven.apache.org/maven2 所以在大多数情况下这并不重要,但为了避免任何角落的情况,请始终使用正确的URL。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接