如何使用Maven pom将jar文件仅下载到特定目录?

发布于 2024-12-09 20:52:29 字数 110 浏览 0 评论 0原文

有没有办法将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

撩心不撩汉 2024-12-16 20:52:29

看一下maven的依赖插件,特别是
复制依赖项
目标。 使用部分描述了如何做正是您想要的。

要从命令行执行此操作,只需执行以下操作:

$ mvn dependency:copy-dependencies -DoutputDirectory=OUTPUT_DIR

添加此内容以排除传递或内部依赖项:

-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:

$ mvn dependency:copy-dependencies -DoutputDirectory=OUTPUT_DIR

Add this to exclude the transitive or inner dependencies:

-DexcludeTransitive=true

仅此而已 2024-12-16 20:52:29

正如此处所解释的< /a>,您可以使用 maven-dependency-plugin:get< /a> 对于 这。

例如,如果您想在本地文件夹中下载org.apache.hive:hive-common:2.1.1,请执行以下命令:

mvn dependency:get -Ddest=./ -Dartifact=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 快照存储库,执行以下命令:

mvn dependency:get -Ddest=./ -DremoteRepositories=sonatype-nexus-snapshots::::https://oss.sonatype.org/content/repositories/snapshots -Dartifact=com.orientechnologies:orientdb-community-gremlin:3.0.0-SNAPSHOT:tar.gz

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:

mvn dependency:get -Ddest=./ -Dartifact=org.apache.hive:hive-common:2.1.1

If you want to download the latest 3.0.0-SNAPSHOT:tar.gz version of com.orientechnologies:orientdb-community-gremlin from https://oss.sonatype.org/content/repositories/snapshots snapshots repository, execute this:

mvn dependency:get -Ddest=./ -DremoteRepositories=sonatype-nexus-snapshots::::https://oss.sonatype.org/content/repositories/snapshots -Dartifact=com.orientechnologies:orientdb-community-gremlin:3.0.0-SNAPSHOT:tar.gz
握住我的手 2024-12-16 20:52:29

在 pom.xml 中添加类似以下内容:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <configuration>
        <outputDirectory>
            ${project.build.directory}
        </outputDirectory>
    </configuration>
</plugin>

然后运行 ​​mvn clean dependency:copy-dependencies 来执行复制。
将此与 程序集插件 结合起来,您可以将所有内容打包到一个独立的存档中用于分发。

Add something similar to the following to pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <configuration>
        <outputDirectory>
            ${project.build.directory}
        </outputDirectory>
    </configuration>
</plugin>

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.

惯饮孤独 2024-12-16 20:52:29

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

苏别ゝ 2024-12-16 20:52:29
  1. 转到此站点:http://jar-download.com/online -maven-download-tool.php

  2. 插入 Maven 依赖项 XML

  3. 下载将 jar 文件下载为 ZIP 格式。

  1. Go to this site: http://jar-download.com/online-maven-download-tool.php

  2. Insert the Maven dependencies XML

  3. Download the jar files as a ZIP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文