Maven 无法解析 SNAPSHOT 依赖项

Mic*_*che 5 java nexus maven-3 maven

我刚刚使用 SNAPSHOT 版本将 Maven 多模块项目部署到 Nexus。

部署的工件存在于 Nexus 快照存储库中,我可以直接通过 Nexus 界面下载它们。

但是,当我将这些工件作为依赖项添加到另一个项目时,Maven 无法解析它们。

我收到以下错误:

Downloading: http://<nexus-url>/nexus/content/groups/public/<groupId>/<artifactId>/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://<nexus-url>/nexus/content/groups/public/<groupId>/<artifactId>/1.0-SNAPSHOT/maven-metadata.xml (835 B at 15.1 KB/sec)
Downloading: http://<nexus-url>/nexus/content/groups/public/<groupId>/<artifactId>/1.0-SNAPSHOT/<artifactId>-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.056s
[INFO] Finished at: Tue Mar 25 17:49:23 IST 2014
[INFO] Final Memory: 11M/234M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project my-project: Co
uld not resolve dependencies for project com.example:my-project:jar:2.0-SNAPSHOT: Could not find artifact <groupId>:<artifactId>:jar:1.0-SNAPSHOT in nexus (http://<nexus-url>/nexus/content/groups/public) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso
lutionException
Run Code Online (Sandbox Code Playgroud)

请注意,Maven 不会尝试下载文件maven-metadata.xml

谢谢,迈克尔


编辑: Maven 确实会下载文件maven-metadata.xml。使用-U没有帮助。

似乎 Maven 尝试下载工件而不将 SNAPSHOT 转换为适当的时间戳。

cha*_*had 2

也许您需要使用 运行构建-U,这意味着“强制更新依赖项,即使您已经在过去 24 小时内解决了它们”。

如果没有它,maven 只会尝试每天一次解决这些快照依赖关系,您可能已经完成了这一操作,因此您会收到有关它不存在的“缓存”响应。