简体   繁体   English

未从Nexus加载Maven SNAPSHOT版本

[英]Maven SNAPSHOT version not loaded from Nexus

We have a Sonatype Nexus running in our environment which has another Nexus as proxy repository configured. 我们的环境中运行着一个Sonatype Nexus,其中配置了另一个Nexus作为代理存储库。 When we consume our dependencies we ask our Nexus for them. 当我们消耗依赖项时,我们会向Nexus求助。 This worked fine until yesterday when I added a new dependency to our project. 直到昨天,当我向我们的项目中添加了新的依赖项时,这一切都很好。

It seems that Maven is not properly resolving the snapshot versions that are deployed. 看来Maven不能正确解析已部署的快照版本。 In the maven log I can see that it is downloading the maven-metadata.xml but when it tries to download the zip file containing our binaries, it does not replace the -SNAPSHOT with the current snapshot version 在maven日志中,我可以看到它正在下载maven-metadata.xml,但是当它尝试下载包含我们的二进制文件的zip文件时,它不会用当前快照版本替换-SNAPSHOT

> mvn -f My.Product.dependencies.xml process-resources -DConfiguration=AnyConfig -U -X

[DEBUG] Could not find metadata com.company.team:My.New.Dependency:2.2-SNAPSHOT/maven-metadata.xml in local (d:\Maven\repositories)
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://buildserver:8082/nexus/content/groups/company
Downloading: http://buildserver:8082/nexus/content/groups/company/com/company/team/My.New.Dependency/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://buildserver:8082/nexus/content/groups/company/com/company/team/My.New.Dependency/2.2-SNAPSHOT/maven-metadata.xml (850 B at 13.2 KB/sec)
[DEBUG] Reading resolution tracking file d:\Maven\repositories\com\company\team\My.New.Dependency\2.2-SNAPSHOT\resolver-status.properties
[DEBUG] Writing resolution tracking file d:\Maven\repositories\com\company\team\My.New.Dependency\2.2-SNAPSHOT\resolver-status.properties
[DEBUG] Could not find metadata com.company.team:My.New.Dependency:2.2-SNAPSHOT/maven-metadata.xml in local (d:\Maven\repositories)
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://buildserver:8082/nexus/content/groups/company
Downloading: http://buildserver:8082/nexus/content/groups/company/com/company/team/My.New.Dependency/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://buildserver:8082/nexus/content/groups/company/com/company/team/My.New.Dependency/2.2-SNAPSHOT/maven-metadata.xml (850 B at 55.3 KB/sec)
[DEBUG] Reading resolution tracking file d:\Maven\repositories\com\company\team\My.New.Dependency\2.2-SNAPSHOT\resolver-status.properties
[DEBUG] Writing resolution tracking file d:\Maven\repositories\com\company\team\My.New.Dependency\2.2-SNAPSHOT\resolver-status.properties
...
Downloading: http://buildserver:8082/nexus/content/groups/company/com/company/team/My.New.Dependency/2.2-SNAPSHOT/My.New.Dependency-2.2-SNAPSHOT-vs2010-40-AnyCpu-Release.zip
[DEBUG] Reading resolution tracking file d:\Maven\repositories\com\company\team\My.New.Dependency\2.2-SNAPSHOT\My.New.Dependency-2.2-SNAPSHOT-vs2010-40-AnyCpu-Release.zip.lastUpdated
[DEBUG] Writing resolution tracking file d:\Maven\repositories\com\company\team\My.New.Dependency\2.2-SNAPSHOT\My.New.Dependency-2.2-SNAPSHOT-vs2010-40-AnyCpu-Release.zip.lastUpdated
[INFO] ------------------------------------------------------------------------
...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] My.Client.App  FAILURE [1.922s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.687s
[INFO] Finished at: Thu Oct 13 09:54:24 CEST 2016
[INFO] Final Memory: 9M/177M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project My.Client.App: Could not resolve dependencies for project com.company.team2:My.Client.App:pom:7.0-SNAPSHOT: The following artifacts could not be resolved: com.company.team:My.New.Dependency:zip:vs2010-40-AnyCpu-Release:2.2-SNAPSHOT: Could not find artifact com.company.team:My.New.Dependency:zip:vs2010-40-AnyCpu-Release:2.2-SNAPSHOT in company (http://buildserver:8082/nexus/content/groups/company) -> [Help 1]

The maven-metadata.xml contains properly the snapshot version information: maven-metadata.xml正确包含快照版本信息:

<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
  <groupId>com.company.team</groupId>
  <artifactId>My.New.Dependency</artifactId>
  <version>2.2-SNAPSHOT</version>
  <versioning>
    <snapshot>
      <timestamp>20161011.235855</timestamp>
      <buildNumber>102</buildNumber>
    </snapshot>
    <lastUpdated>20161011235855</lastUpdated>
    <snapshotVersions>
      <snapshotVersion>
        <extension>pom</extension>
        <value>2.2-20161011.235855-102</value>
        <updated>20161011235855</updated>
      </snapshotVersion>
      <snapshotVersion>
        <classifier>vs2010-40-AnyCPU-Release</classifier>
        <extension>zip</extension>
        <value>2.2-20161011.235855-102</value>
        <updated>20161011235855</updated>
      </snapshotVersion>
    </snapshotVersions>
  </versioning>
</metadata>

When I check the directory listing of the folder where it downloads the stuff from, the 2.2-20161011.235855-102 version is properly there: 当我检查从中下载内容的文件夹的目录列表时,那里的2.2-20161011.235855-102版本正确存在:

Nexus目录清单

All other dependencies from the same repository work perfectly fine, just the newly introduced one is not dowloaded. 来自同一存储库的所有其他依赖项都可以很好地工作,只是不会下载新引入的依赖项。 It currently drives me crazy that Maven is not replacing the -SNAPSHOT with the actual snapshot version number like it does for all the other dependencies. 目前,让我感到疯狂的是,Maven没有像实际的快照版本号那样替换-SNAPSHOT,就像其他所有依赖项所做的那样。 I also tried the options "Expire Cache" and "Update Index" in the Nexus UI but that didn't help. 我还尝试了Nexus UI中的“过期缓存”和“更新索引”选项,但没有帮助。 What could cause Maven to fall back from the actual version number to the -SNAPSHOT? 是什么导致Maven从实际版本号退回到-SNAPSHOT? There is also no log entry that would explain this. 也没有日志条目可以解释这一点。

After trying 1 million things and comparing the configuration of the other dependencies with the new ones I finally found the issue: The artifact ids (classifiers) are case sensitive. 在尝试了一百万种东西并将其他依赖项的配置与新依赖项进行比较之后,我终于发现了问题:工件ID(分类器)区分大小写。 In my client POM file I was referring to vs2010-40-AnyCpu-Release but deployed is vs2010-40-AnyCPU-Release (notice the capital AnyC PU ). 在我的客户端POM文件中,我指的是vs2010-40-AnyCpu-Release但部署的是vs2010-40-AnyCPU-Release (请注意大写的AnyC PU )。

In the logfile you can see that it tries to download a file with lowercase AnyCpu. 在日志文件中,您可以看到它尝试下载小写AnyCpu文件。 After I changed it to uppercase it worked. 在将其更改为大写之后,它起作用了。

You have a file 你有一个文件

My.New.Dependency-2.2-SNAPSHOT-vs2010-40-AnyCpu-Release.zip.lastUpdated

in your local repository. 在您的本地存储库中。 Try to delete it. 尝试删除它。 It can block Maven from reattempting the download. 它可以阻止Maven重新尝试下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM