如何使用Maven pom将jar文件仅下载到特定目录?
有没有办法将pom.xml文件中的依赖项下载到java中的指定文件夹?我可以从 java 运行 maven 命令并且收到下载消息,但我不知道 maven 在哪里存储这些库?如何将这些依赖项下载到特定文件夹?
Is there a way to download dependencies from a pom.xml file to a specified folder in java? I'm able to run maven command from java and I got download messages, but I don't know where maven stores these libraries? How can I download these dependencies to a specific folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
看一下maven的依赖插件,特别是
复制依赖项
目标。 使用部分描述了如何做正是您想要的。要从命令行执行此操作,只需执行以下操作:
添加此内容以排除传递或内部依赖项:
-DexcludeTransitive=true
Take a look at maven's dependency plugin, specifically the
copy-dependencies
goal. The usage section describes how to do exactly what you want.To do it from the command line just do:
Add this to exclude the transitive or inner dependencies:
-DexcludeTransitive=true
正如此处所解释的< /a>,您可以使用 maven-dependency-plugin:get< /a> 对于 这。
例如,如果您想在本地文件夹中下载
org.apache.hive:hive-common:2.1.1
,请执行以下命令:如果您想下载最新的
3.0.0- SNAPSHOT:tar.gz
版本的com.orientechnologies:orientdb-community-gremlin
来自https://oss.sonatype.org/content/repositories/snapshots
快照存储库,执行以下命令:As explained here, you can use maven-dependency-plugin:get for this.
For example, if you want to download
org.apache.hive:hive-common:2.1.1
in your local folder, execute this:If you want to download the latest
3.0.0-SNAPSHOT:tar.gz
version ofcom.orientechnologies:orientdb-community-gremlin
fromhttps://oss.sonatype.org/content/repositories/snapshots
snapshots repository, execute this:在 pom.xml 中添加类似以下内容:
然后运行 mvn clean dependency:copy-dependencies 来执行复制。
将此与 程序集插件 结合起来,您可以将所有内容打包到一个独立的存档中用于分发。
Add something similar to the following to pom.xml:
Then run
mvn clean dependency:copy-dependencies
to perform the copy.Combine this with the assembly plugin and you can package everything into a self contained archive for distribution.
Maven 将所有这些存储在其本地 Maven2 存储库中。默认情况下,它会将它们存储在您的用户主目录中名为存储库的目录下。
您可以使用 maven-dependency-plugin 的目标“复制”来获取项目的所有依赖项并将它们放入一个文件夹中。
http://maven.apache.org/plugins/maven-dependency -plugin/copy-mojo.html
Maven stores all of these in it's local Maven2 repository. By default, it will store them in your user home directory under a directory called repository.
You can use the maven-dependency-plugin's goal called copy to take all of your project's dependencies and put them in a folder.
http://maven.apache.org/plugins/maven-dependency-plugin/copy-mojo.html
转到此站点:http://jar-download.com/online -maven-download-tool.php
插入 Maven 依赖项 XML
下载将 jar 文件下载为 ZIP 格式。
Go to this site: http://jar-download.com/online-maven-download-tool.php
Insert the Maven dependencies XML
Download the jar files as a ZIP.