【问题标题】:Not retrieving jars from maven nexus setup specific to project不从特定于项目的 maven nexus 设置中检索 jars
【发布时间】:2020-01-02 08:51:39
【问题描述】:

有 2 个 Nexus maven repo - 一个服务或持有普通罐子 - 主要来自 maven Central 和其他一些。以及其他 - 项目特定的 maven nexus,其中包含 2 个第三方 jar,这些 jar 是编译当前感兴趣的项目所必需的。

以下是添加以引用本地 nexus maven 设置和相应依赖项的更新..

pom.xmlsn-p:

<project 
...


<!-- download plugins from this *proj specific* repo -->
<repositories>
 <repository>
  <id>zzz-maven</id>
  <name>zzz-maven</name>
  <url>http://blah.blah.com/nexus/content/repositories/zzz-maven</url>
  <releases>
   <enabled>true</enabled>
  </releases>
  <snapshots>
   <enabled>true</enabled>
  </snapshots>
 </repository>
</repositories>

    <dependencies>
        <dependency>
        <groupId>zzz.zzz-report<groupId>
        <artifactId>zzz-report<artifactId>
        <version>1.2<version>
    </dependency>
    ...
    <!-- And other dependency to fetch jars from common nexus (which is working fine) -->

在下面添加到settings.xml(以粗体文本突出显示) - 一个涵盖用于检索项目特定 jar 的 URL 以及对项目特定 Nexus 进行身份验证的其他部分

<settings>   
  <mirrors>
    <mirror>
      <id>nexus</id>
      <name>Common nexus across org - Anonymous access </name>
      <url>http://common-nexusxyz.com/nexus/content/repositories/maven</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>


  <profiles>
     </profile>
     <profile>
      <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>

    <!--**Added this one** -->       
    </profile>
     <profile>
      <id>zzz-maven</id>
      <repositories>
        <repository>
          <id>zzz-maven</id>
          <name>zzz-maven</name>
          <url>http://blah.blah.com/nexus/content/repositories/zzz-maven</url>
        </repository>
      </repositories>
    </profile>

  </profiles>

  <activeProfiles>
    <activeProfile>nexus</activeProfile>
    <activeProfile>zzz-maven</activeProfile>  <!--**activated** additional one here -->
  </activeProfiles>

<servers>
  <server>   
   <id>zzz-maven</id>
   <username>userNameForZZZ</username> <!--**Specified** explicit password needed for proj specific maven nexus here -->
   <password>passwordForZZZ</password>
  </server>
</servers>

</settings>

但仍然会抛出警告,然后是 mvn installmvn compile 的错误,例如:

[WARNING] The POM for zzz.zzz-report:zzz-report:jar:1.2 is missing, no dependency information available

想知道缺少什么 - 以便它可以从项目特定的 maven nexus 下载项目特定的 jar?

尝试在 pom 中同时使用 &lt;repositories&gt;&lt;pluginRepositories&gt; 选项以考虑下载

期望它连接到项目特定的 maven nexus 并下载 pom 中定义的依赖 jar

【问题讨论】:

    标签: maven download dependencies settings nexus


    【解决方案1】:

    你已经定义了

    <mirror>
      <id>nexus</id>
      <name>Common nexus across org - Anonymous access </name>
      <url>http://common-nexusxyz.com/nexus/content/repositories/maven</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
    

    这意味着所有请求(由于 mirrorOf 具有值 *)都被重定向到该特定存储库,无论 POM 或 settings.xml 中定义了哪些其他存储库。

    【讨论】:

    • 感谢您的回复。已尝试使用 &lt;mirrorOf&gt;central,zzz-maven&lt;/mirrorOf&gt; - 但仍然看到类似的问题,即无法下载位于项目特定 maven nexus 中的项目特定 jar
    • 我以为你想要使用zzz-maven?使用您的配置,您将所有对 zzz-maven 的调用替换为您定义的镜像。
    • 是的,我想使用zzz-maven Nexus 来考虑下载常见连接上不存在的 jar(其中 2 个)。因此扫描zzz-maven 已将其添加为逗号分隔值而不是* 根据您的回答..
    • 试试&lt;mirrorOf&gt;*,!central,!zzz-maven&lt;/mirrorOf&gt;
    • 非常感谢!,它就像魅力一样。接受了答案。如果可能,请编辑您的答案以供其他人参考。
    猜你喜欢
    • 2011-07-10
    • 1970-01-01
    • 1970-01-01
    • 2015-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-05
    相关资源
    最近更新 更多