将依赖项下载到本地存储库,而不下载到“目标"存储库.一 [英] Download dependencies to local repository but not to "target" one

查看:121
本文介绍了将依赖项下载到本地存储库,而不下载到“目标"存储库.一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,该项目具有pom.xml,并且依赖于外部的大量依赖关系(位于Internet的远处.).

I have a project, that has pom.xml and depends on lots of dependencies from outside (located far-far in internet..).

因此,我想将所有依赖项下载到本地存储库"中.

So, I want to download all those dependencies which I depend on to my "local repository".

这是我的尝试(我不需要编译,因此在这里使用"validate".因此,我不希望最后使用"target"文件夹):

This is my try (I do not need do compilation, so I use "validate" here. So I'm do not expect to have "target" folder in the end):

mvn validate -Dmaven.repo.local=C:\my\.m2\repository dependency:copy-dependencies 

最后-是的,我有许多依赖项已下载到"C:\my\.m2\repository",但是其中一些依赖项已转到:C:\projects\myProject\java\trunk\target\dependency,就像这些依赖项:

In the end - yes I have many dependencies been downloaded to "C:\my\.m2\repository", but some of them went to: C:\projects\myProject\java\trunk\target\dependency, like these ones:

junit-4.8.1.jar
log4j-1.2.8.jar
mockito-all-1.8.2.jar

问题是:如何将其下载到项目的"C:\my\.m2\repository"而不是"target"?

Question is: how to make those to be downloaded to "C:\my\.m2\repository" but not to "target" of my project?

目前,因此,依赖该项目的另一个项目在构建时失败了,因为他们希望在本地存储库中找到"junit-4.8.1.jar".

For now, because of that, another projects that depend on that are failing while building, because they are expecting to find "junit-4.8.1.jar" in local repo.

另一种尝试:

mvn validate -Dmaven.repo.local=C:\my\.m2\repository dependency:resolve

然后这些依赖项根本无法解决.

Then those dependencies are not resolvable at all.

无法解析项目bla-bla-SNAPSHOT的依赖项: 以下工件无法解决: commons-lang:commons-lang:jar:2.4,log4j:log4j:jar:1.2.8, junit:junit:jar:4.8.1:找不到工件 commons-lang:commons-lang:jar:2.4-> [帮助1]

Could not resolve dependencies for project bla-bla-SNAPSHOT: The following artifacts could not be resolved: commons-lang:commons-lang:jar:2.4, log4j:log4j:jar:1.2.8, junit:junit:jar:4.8.1: Could not find artifact commons-lang:commons-lang:jar:2.4 -> [Help 1]

推荐答案

Maven这样做是因为您调用了目标dependency:copy-dependencies.它将当前模块的依赖项复制到

Maven did that because you invoked the goal dependency:copy-dependencies. It will copy the dependencies of the current module to

 ${project.build.directory}/dependency

请参见 http://maven.apache.org /plugins/maven-dependency-plugin/copy-dependencies-mojo.html

我真的无法想象这些依赖项没有进入您的本地仓库.摆弄脚本可能无法解决您的问题.试试

I really can't imagine these dependencies did not get into your local repo. Fiddling around with a script may not be the solution to your problem. Try

 mvn process-resources -U -Dmaven.repo.local=C:\my\.m2\repository

-U选项强制下载所有依赖项.我建议使用process-resources,尽管据我所知validate也应该很好.

The -U option forces a download of all dependencies. I suggest using process-resources, although as of my understanding validate should be fine, too.

这篇关于将依赖项下载到本地存储库,而不下载到“目标"存储库.一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆