我目前无法尝试添加另一个Maven项目(特别是Aerospike)的依赖项添加到我的项目中。我已经在Aerospike项目上做了mvn install
所以在我的存储库中(在Linux上:〜/ .m2 / repository / com / aerospike / aerospike-client / 3.0.6)我看到了一个aerospike-client-3.0.6 .jar.lastUpdated文件。但是,当我添加依赖
<dependency>
<groupId>com.aerospike</groupId>
<artifactId>aerospike-client</artifactId>
<version>3.0.6</version>
<scope>compile</scope>
</dependency>
进入我的项目并执行mvn install
,它会返回此错误:
[INFO] ------------------------------------------------------------------------
[INFO] Building in-memory database poc 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.aerospike:aerospike-client:jar:3.0.6 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.601s
[INFO] Finished at: Fri Aug 16 11:49:43 EDT 2013
[INFO] Final Memory: 18M/954M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project: Could not resolve dependencies for project: Failure to find com.aerospike:aerospike-client:jar:3.0.6 in http://repository.jboss.org/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of jboss-public-repository-group 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
提前致谢!
答案 0 :(得分:1)
控制台输出显示Maven正在JBoss public repository中搜索com.aerospike:aerospike
工件,但该工件不存在。
Failure to find com.aerospike:aerospike-client:jar:3.0.6 in
http://repository.jboss.org/nexus/content/groups/public
OP说他在当地安装了它。
Maven正在尝试从没有该工件的远程存储库下载本地安装的工件。首先在本地存储库中搜索By default个依赖项。 AFAIK,唯一可以覆盖此行为的是settings.xml
中定义的artifact update policies。
AFAIK,离线版本(-o
)应该覆盖任何此类政策。
我尝试通过删除本地存储库中的依赖项并故意声明不存在的依赖项来重现这种情况,并且Maven按照文档记录(脱机构建不尝试下载)。我没有玩过更新政策。
跟进评论,我已在以下环境中验证了脱机构建过程:
Apache Maven 3.1.0
Java version: 1.7.0_25, vendor: Oracle Corporation
OS name: "linux", version: "3.2.0-23-generic", arch: "amd64", family: "unix"
离线构建程序简而言之:
所有命令都从项目根文件夹运行。
首先,从您的pom中评论在任何远程存储库中找不到的所有依赖项,例如:
<!--
<dependency>
<groupId>does</groupId>
<artifactId>not</artifactId>
<version>exist</version>
</dependency>
-->
准备offline build by downloading all the dependencies:
mvn dependency:go-offline
如果您没有注释掉缺少的依赖项,则此目标将失败。您可以通过观察Maven 成功下载控制台输出中的所有工件来验证它。
接下来,安装缺少的依赖项manually in your local repo:
mvn install:install-file -Dfile=<PATH_TO_MISSING_DEP_JAR_FILE>
-DgroupId=does
-DartifactId=not
-Dversion=exist
-Dpackaging=jar
这将生成not-exist.jar
(&lt; PATH_TO_MISSING_DEP_JAR_FILE&gt;的副本)和not-exist.pom
以及<LOCAL_REPO_PATH>/.m2/repository/does/not/exist/
下的本地存储库中的元数据文件
验证这些文件存在于该确切的目录结构下。 不同平台的本地存储库的默认位置为here,但如果不存在,则运行:
mvn help:effective-settings > settings.log
将您项目的interpolated settings转储到settings.log
文件。在文本编辑器和read the path of your local repo下打开它:
<settings>
...
<localRepository>/path/to/local/repo/</localRepository>
...
</settings>
现在您可以在离线模式下运行构建:
mvn clean install -o
您也可以设置offline mode in your settings file,但这会为a specified user or system-wide设置离线模式,而不是每个项目的命令行开关。
小心完全按照运行此程序,如果您仍无法构建项目,请运行:
mvn help:effective-pom > pom.log
mvn help:effective-settings > settings.log
并在此处发布pom.log
和settings.log
个文件的内容。