如何将特定的 Maven 工件从存储库下载到本地驱动器?

How can I download a specific Maven artifact from repository to local drive?

有时我们可能希望将特定的 Maven 工件从存储库下载到本地驱动器。 就我而言,我想在特定 IDE 中使用在 Maven 存储库中发布的第三方库。然而,我使用的 IDE 还没有对 Maven 存储库的集成支持,因此使用这个库的唯一方法是将工件下载到我的本地驱动器。 我是 Maven 的新手,任何建议将不胜感激。谢谢

-----更新-----

我从其他线程学习并意识到我应该使用 maven 依赖插件将工件下载到本地文件夹。就我而言,我需要从 Maven 存储库下载 google ARCore。我在 maven 存储库中搜索 ARCore,并且知道:

类别:com.google.ar、Group:core、version:1.1.0

所以我使用了下面的命令行来下载它:

mvn dependency:get -Dartifact=com.google.ar:core:1.1.0

然而,下载工件失败,错误消息如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project standalone-pom: Couldn't download artifact: Missing:
[ERROR] ----------
[ERROR] 1) com.google.ar:core:jar:1.1.0
[ERROR]
[ERROR]   Try downloading the file manually from the project website.
[ERROR]
[ERROR]   Then, install it using the command:
[ERROR]       mvn install:install-file -DgroupId=com.google.ar -DartifactId=core -Dversion=1.1.0 -Dpackaging=jar -Dfile=/path/to/file
[ERROR]
[ERROR]   Alternatively, if you host your own repository you can deploy the file there:
[ERROR]       mvn deploy:deploy-file -DgroupId=com.google.ar -DartifactId=core -Dversion=1.1.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR]   Path to dependency:
[ERROR]         1) org.apache.maven.plugins:maven-downloader-plugin:jar:1.0
[ERROR]         2) com.google.ar:core:jar:1.1.0
[ERROR]
[ERROR] ----------
[ERROR] 1 required artifact is missing.

有人可以帮忙吗?谢谢

如果您查看 artifact 选项的文档: groupId:artifactId:version[:packaging][:classifier]. 形式的字符串 查看它的最后一个(可选)标记 [:classifier]。我想这就是你所缺少的。 试试这个, mvn dependency:get -Dartifact=com.google.ar:core:1.1.0:jar:jar-with-dependencies