如何将依赖项从 pom 加载到 eclipse 项目的类路径中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6072583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to load the dependencies from the pom into classpath of eclipse project?
提问by Rajan
Am using eclipse helios with m2eclipse plugin. For a maven project checked out from CVS, how do i tell eclipse to automatically fetch all the jars needed for that project from the dependencies mentioned in the pom.
我正在使用带有 m2eclipse 插件的 eclipse helios。对于从 CVS 检出的 Maven 项目,我如何告诉 eclipse 从 pom.xml 文件中提到的依赖项中自动获取该项目所需的所有 jar 包?
Thanks for your time
谢谢你的时间
采纳答案by FrVaBe
m2eclipse should do this for you (dependencies will be copied to your local repository) and build a valid classpath. I you have any doubts that the resolved dependencies are outdated try
m2eclipse 应该为您执行此操作(依赖项将被复制到您的本地存储库)并构建一个有效的类路径。我怀疑已解决的依赖项已过时,请尝试
<select project> -> Context Menu -> Maven -> Update Dependencies
If you want to guarantee that all dependencies (and plugins) are in your local repository you can run the go-offlinegoal from the Maven Dependency Plugin:
如果您想保证所有依赖项(和插件)都在您的本地存储库中,您可以从Maven Dependency Plugin运行go-offline目标:
mvn dependency:go-offline
If you want to copy all needed dependencies to one place, use the copy-dependenciesgoal
如果要将所有需要的依赖项复制到一个位置,请使用copy-dependencies目标
mvn dependency:copy-dependencies
The Maven Dependency Plugin will copy all dependencies (including transitive) to the target/dependency
folder in this case.
target/dependency
在这种情况下,Maven Dependency Plugin 会将所有依赖项(包括可传递的)复制到文件夹中。
You can run all these commands also from eclipse using:
您也可以使用以下命令从 Eclipse 运行所有这些命令:
<select project> -> Context Menu -> Run As -> Maven build... -> <type goals> -> Run