【问题标题】:How can I download a specific Maven artifact from repository to local drive?如何将特定的 Maven 工件从存储库下载到本地驱动器?
【发布时间】:2018-09-22 19:48:39
【问题描述】:

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

--更新------

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

类别:com.google.ar,组:core,版本: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.

有人可以帮忙吗?谢谢。

【问题讨论】:

标签: maven maven-2 maven-3


【解决方案1】:

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

【讨论】:

  • 我认为你的建议应该是正确的。但不知何故,它仍然声称该神器丢失了。幸运的是,我从其他来源获得了神器。附言该库被打包为 aar 文件。
猜你喜欢
  • 2017-04-23
  • 1970-01-01
  • 2012-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-02
  • 2014-02-15
  • 1970-01-01
相关资源
最近更新 更多