我们在我们的环境中运行了一个Sonatype Nexus,它配置了另一个Nexus作为代理存储库。当我们消耗我们的依赖关系时,我们会向Nexus询问它们。直到昨天我为我们的项目添加了一个新的依赖项,这个工作正常。
Maven似乎没有正确解析部署的快照版本。在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]
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>
当我检查从中下载内容的文件夹的目录列表时,2.2-20161011.235855-102版本是正确的:
来自同一存储库的所有其他依赖项都可以正常工作,只是新引入的依赖项不会被下载。它目前让我很生气,因为Maven并没有将-SNAPSHOT替换为实际的快照版本号,就像它对所有其他依赖项一样。我也尝试过选项&#34; Expire Cache&#34;和&#34;更新索引&#34;在Nexus UI中,但没有帮助。什么可能导致Maven从实际版本号回退到-SNAPSHOT?也没有可以解释这一点的日志条目。
答案 0 :(得分:2)
在尝试了100万件事并将其他依赖关系的配置与新的配置进行比较后,我终于找到了问题:工件ID(分类器)区分大小写。在我的客户端POM文件中,我指的是 function myHandler() {
i++;
if(i >= videoCount) i =0;
videoPlay(i);
}
,但部署的是vs2010-40-AnyCpu-Release
(注意资本AnyC PU )。
在日志文件中,您可以看到它尝试下载带有小写AnyCpu的文件。在我将其更改为大写后,它起作用了。
答案 1 :(得分:0)
你有一个文件
My.New.Dependency-2.2-SNAPSHOT-vs2010-40-AnyCpu-Release.zip.lastUpdated
在您的本地存储库中。尝试删除它。它可以阻止Maven重新尝试下载。