【问题标题】:Nexus Won't Serve SNAPSHOTs From Default Public GroupNexus 不会提供来自默认公共组的快照
【发布时间】:2011-07-11 06:11:02
【问题描述】:

由于某种原因,我无法让 Nexus 通过默认公共组提供我的 SNAPSHOT 工件。我已经阅读了 Nexus 手册的相关部分并搜索了谷歌,但我所做的一切似乎都不起作用。

我已经实现了第 4.2 节中的内容。 (Configuring Maven to Use a Single Nexus Group) 的手册,所以我的 settings.xml 看起来像:

<settings>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://my-server/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <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>

</settings>

一切正常,直到我开始在一台干净的机器上构建东西(即我没有构建任何 SNAPSHOT 项目的机器)并且它不会下载所需的 SNAPSHOT 依赖项。 Maven 给了我以下信息:

[INFO] Scanning for projects...
[INFO]       
[INFO] ------------------------------------------------------------------------
[INFO] Building MyCo Actions Base Classes 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/testing-1.0.0-SNAPSHOT.pom
[WARNING] The POM for com.myco:testing:jar:1.0.0-SNAPSHOT is missing, no dependency information available
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/testing-1.0.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.023s
[INFO] Finished at: Tue Mar 08 15:55:23 GMT 2011
[INFO] Final Memory: 99M/480M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project actions-base: Could not resolve dependencies for project com.myco:actions-base:jar:1.0.0-SNAPSHOT: Could not find artifact com.myco:testing:jar:1.0.0-SNAPSHOT in nexus (http://my-sever/nexus/content/groups/public) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

问题是 testing-1.0.0-SNAPSHOT.jar 不存在,但 testing-1.0.0-20110301.182820-1.jar 存在。如何让 Nexus 正确解决 SNAPSHOT 并为我提供我的 JAR...?

【问题讨论】:

    标签: maven nexus snapshot


    【解决方案1】:

    我最终完成了从公共组中删除本地版本和快照存储库并制作镜像的工作,只镜像公共组而不是所有内容。所以我的 settings.xml 最终包含:

      <profiles>
        <profile>
          <id>nexus</id>
          <activation>
            <activeByDefault>true</activeByDefault>
          </activation>
          <repositories>
            <repository>
              <id>maven-releases</id>
              <url>http://myhost.com/nexus/content/repositories/releases</url>
              <layout>default</layout>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
            </repository>
            <repository>
              <id>maven-snapshots</id>
              <url>http://myhost.com/nexus/content/repositories/snapshots</url>
              <layout>default</layout>
              <releases>
                <enabled>false</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </repository>        
            <repository>
              <id>madeUp</id>
              <url>http://central</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </repository>
          </repositories>
          <pluginRepositories>
            <pluginRepository>
              <id>madeUp</id>
              <url>http://central</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </pluginRepository>
          </pluginRepositories>
        </profile>
      </profiles>
    
      <mirrors>
        <mirror>
          <id>nexus</id>
          <mirrorOf>madeUp</mirrorOf>
          <url>http://myhost.com/nexus/content/groups/public</url>
        </mirror>
      </mirrors>
    

    【讨论】:

      【解决方案2】:

      在将 nexus 配置为镜像时,我遇到了同样的问题。在Public Repository组中添加所有存储库(发布和快照)后,您可以通过浏览相应的URL找到所有快照:

      但是 maven 无论如何都无法从镜像中获取快照,如该线程中所述。它接缝 maven 不会从镜像中检索快照,直到您明确告诉它这样做。作为一种解决方案,我添加了与 repository-Tag 相同的 URL,它按预期工作:

      <settings>
      
      <mirrors>
          <mirror>
              <id>nexus-mirror</id>
              <name>Nexus Mirror</name>
              <url>http://my-server/nexus/content/groups/public/</url>
              <mirrorOf>*</mirrorOf>
          </mirror>
      </mirrors>
      
      <profiles>
          <profile>
              <activation>
                  <activeByDefault>true</activeByDefault>
              </activation>
              <repositories>
                  <repository>
                      <id>nexus-public</id>
                      <name>Nexus Public Repository</name>
                      <url>http://my-server/nexus/content/groups/public/</url>
                      <releases>
                          <enabled>true</enabled>
                      </releases>
                      <snapshots>
                          <enabled>true</enabled>
                          <updatePolicy>always</updatePolicy>
                      </snapshots>
                  </repository>
              </repositories>
          </profile>
      </profiles>
      
      </settings>
      

      即使将 updatePolicy-Tag 设置为整个镜像也不会造成任何麻烦。因为 maven 足够聪明,只更新每个构建中的快照,而不是版本。

      【讨论】:

      • 我们在尝试在 Jenkins 中构建应用程序时遇到了麻烦。所以我们必须用这些行创建一个自定义的 settings.xml 文件: truealways 然后把这个文件放到 Jenkins,config build ->advanced ->设置文件->文件系统中的设置文件->文件路径。
      【解决方案3】:

      我也试过了,但失败了。问题here 有第二个描述。可能是 Nexus 公共回购干扰了一些事情。

      我最终在 settings.xml 中添加了第二个存储库,更直接地指向我们的本地快照存储库。

      <repository>
         <id>ummsSnaps</id>
            <url>https://team/nexus/content/repositories/snapshots</url>
            <snapshots>
               <enabled>true</enabled>
            </snapshots>
      </repository>
      

      它奏效了。

      【讨论】:

        【解决方案4】:

        检查您的快照存储库是否已添加到您的公共组。看起来您已经正确配置了 settings.xml,所以它一定是 /public 不包含您的快照存储库。

        【讨论】:

        • 快照仓库被添加到公共组中,如果我没记错的话,它默认在那里。
        • 我也有同样的问题。完全相同的 settings.xml + Public 组按顺序包含这些存储库:Release Snapshots 3dParty Central。使用 OSS 2.6.3-01。通过 UI 浏览 Public 时,我可以看到那里的所有工件,但 Maven 无法下载这些工件。这是一个错误还是预期的行为?我以为是组库的功能
        猜你喜欢
        • 2013-12-02
        • 2020-11-22
        • 1970-01-01
        • 2019-11-02
        • 1970-01-01
        • 1970-01-01
        • 2020-09-21
        • 1970-01-01
        • 2011-02-26
        相关资源
        最近更新 更多