【问题标题】:Configure multiple repository, Custom Repo, Maven Central and Pentaho together一起配置多个仓库、自定义仓库、Maven Central 和 Pentaho
【发布时间】:2014-03-16 14:13:00
【问题描述】:

我使用过 Sonatype Nexus 仓库管理,我的需求如下:

  1. 首先应该显示我的自定义 Nexus 存储库,maven 应该首先检查那里
  2. 如果某些 jars 不存在,那么它应该转到 Maven Central
  3. 对于那些甚至不在 Maven Central 中的 jar,比如 (Eigenbase-XOM),它应该转到 PentaHo

但是事情对我不起作用,显示 EigenBase XOM is missing artifact 错误,因为它没有被下载

如果有人可以提供帮助,那将是一个很大的帮助。请让我知道我哪里错了?

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <mirrors>
    <mirror>
      <id>MyRepo</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:port/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
   <profile>
      <id>MyRepo</id>
     <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
        <id>pentaho-releases</id>
        <url>http://repository.pentaho.org/artifactory/repo/</url>
               </repository>
     </repositories>
         <pluginRepositories>
        <pluginRepository>
          <id>central</id>
           <url>http://central</url>
            </pluginRepository>
      </pluginRepositories>
</profile>
  <activeProfiles>
    <activeProfile>MyRepo</activeProfile>
  </activeProfiles>
</settings>

【问题讨论】:

  • 最简单的解决方案是在 Nexus 中配置一个存储库组。然后配置 Maven 客户端使用它。

标签: maven-3 pom.xml nexus


【解决方案1】:

@Manfred Moser:是的,你是对的。在网上搜索后,我得到了同样的技巧。

更详细的答案是: 1)创建一个新的存储库。 2)将该存储库添加到存储库组 3)您还可以更改存储库解析顺序

示例设置 XML 是: {

    <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>MyRepo</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:port/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
   <profile>
      <id>MyRepo</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to MyRepo 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>
    <activeProfile>MyRepo</activeProfile>
</activeProfiles>
</settings>

}

【讨论】:

    【解决方案2】:

    只需使用公共组的简单设置并将代理存储库添加到该组即可。更多详情请见Nexus book chapter on Maven usage

    组列表中仓库的顺序可以随意控制解析顺序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      • 2013-09-28
      • 1970-01-01
      • 1970-01-01
      • 2019-03-22
      • 2019-06-22
      • 2014-03-06
      相关资源
      最近更新 更多