Maven没有下载/识别快照

时间:2013-06-27 16:10:53

标签: download maven-3 snapshot

我们在团队中使用Maven / Nexus / Hudson。我们的Hudson服务器上的Maven版本是3.0.4,并且在构建作业时已停止能够下载快照依赖项。我不确定发生了什么变化(团队没有做任何事,所以他们说),但是发生了一些事情,因为周一早上工作的版本在星期一下午停止工作。

当我尝试在Hudson中构建一个具有快照依赖项的项目时,我收到此错误:

[WARNING] The POM for com.company:my-client:jar:1.9-SNAPSHOT is missing, no dependency information available

我相信我已经解决了Maven没有下载maven-metadata.xml文件的问题,因此无法解析对时间戳版本的依赖性。例如,在我的本地构建中(使用Maven 3.0.3),我在Maven输出中看到了这一点:

Downloading: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/maven-metadata.xml
Downloaded: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/maven-metadata.xml (1004 B at 20.0 KB/sec)
Downloading: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/my-client-1.9-20130625.202822-1.pom
Downloaded: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/my-client-1.9-20130625.202822-1.pom (3 KB at 57.5 KB/sec)
...
Downloading: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/my-client-1.9-20130625.202822-1.jar
...
Downloaded: http://ip:8080/nexus/content/groups/public/com/company/my-client/1.9-SNAPSHOT/my-client-1.9-20130625.202822-1.jar (10 KB at 153.9 KB/sec)

两个版本都在访问我们的Nexus repo,Hudson Maven从它访问非快照依赖项没有问题,因此它不是连接问题。

为什么Maven无法识别SNAPSHOT并下载maven-metadata.xml以获取依赖项的最新时间戳版本?

2 个答案:

答案 0 :(得分:2)

经过多次拉扯之后,我们发现hudson用户的settings.xml文件已删除了nexus配置文件。这似乎具有无法查询快照存储库的效果,尽管它可能会从发布存储库获取工件。

在我们修复文件之前,文件的最后一次编辑是5月29日,所以在6月24日上午而不是下午建造工作的原因仍然是个谜。也许有些东西被缓存了,而且还得到了更新。

答案 1 :(得分:0)

我也遇到了这个问题。我们无意中通过将源存储库添加到我们的项目POM中解决了该问题。尽管仍在通过我们的镜像进行路由,但此更改仍使项目可以将元数据解析为最新的快照版本。

示例:

<project>
    <repositories>
        <repository>
            <id>XYZ-SNAPSHOTS</id>
            <url>http://nexus.xyz.org/nexus/content/groups/enterprise-snapshots/</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
    </repositories>
</project>

事实上,我发现我们没有正确配置镜像。真正的问题似乎是,即使在Nexus本身中启用了快照,也未在settings.xml中的镜像上启用快照。

当我在项目中添加存储库时,我启用了快照而没有考虑它,然后允许Maven解析快照。可以解决此问题,但是更好的解决方案是更新settings.xml以针对所有镜像存储库进行修复。

作为参考,这是正确的settings.xml配置(取自Sonatype):

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/repository/maven-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>