Maven没有选择本地安装的依赖项

时间:2020-10-09 20:05:50

标签: maven

我下载并导入了一个名为Project-A的多模块Maven项目。在安装其模块之一后,将模块A1插入我的本地存储库中,然后可以在存储库目录中看到它。

我创建了另一个项目B,它具有moduleA1作为依赖项。但是当我尝试打包Project-B时,我注意到maven在在线中央存储库中搜索moduleA1,但是失败了。

这是我得到的错误:

[ERROR] Failed to execute goal on project <project-B>: Could not resolve dependencies for project <Project-B>:war:1.0: Failed to collect dependencies at <moduleA1>:jar:<version>: Failed to read artifact descriptor for <moduleA1>:jar:<version>: Failure to find <moduleA1-groupId>:<moduleA1>:pom:<version> in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [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

如何使Maven从本地存储库解决此moduelA1依赖性。

2 个答案:

答案 0 :(得分:1)

如果您有一些引用父pom的子项目(在您的情况下为moduleA1),并且尚未从父pom目录安装(从父目录运行mvn install(即您的Project-A),则可能会发生此问题。案件))。如果一个子项目(在您的情况下为moduleA1)可能依赖于同级项目(假设您有另一个模块moduleA2),并且当它去读取同级项目的pom时,它将失败,并出现问题中提到的错误,除非您已从父pom目录至少安装了一次。因此,只需尝试运行:

mvn -U clean install

从您的Project-A目录

答案 1 :(得分:0)

Maven自动解决本地存储库中的依赖项。

没有确切的错误消息,很难给出更准确的答案。