java 如何将 Maven 工件从远程存储库下载到本地文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27394176/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 11:43:21  来源:igfitidea点击:

How download maven artifact from remote repository to local folder?

javamavendependency-management

提问by Cherry

I am writing a script for deploying java application. The scenarion is simple:

我正在编写一个用于部署 Java 应用程序的脚本。场景很简单:

  1. Download pusblished application (jar) from repository to local folder.
  2. Run java with jar
  1. 将已发布的应用程序 (jar) 从存储库下载到本地文件夹。
  2. 用 jar 运行 java

How can I download this jar from maven repo to local folder?

如何将这个 jar 从 maven repo 下载到本地文件夹?

Important

重要的

  1. The question is notabout resolving one artifact. Hereis a solution to donwload single artifact to local repository, but I want to specified folder.
  2. Also the solution should work from command line withoutpom file. E.g. run mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:copywill fail, because it runs only in folder where pom.xmlis present.
  1. 问题在于解决一个工件。是将单个工件下载到本地存储库的解决方案,但我想指定文件夹。
  2. 此外,该解决方案应该在没有pom 文件的命令行中工作。例如运行mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:copy将失败,因为它仅在pom.xml存在的文件夹中运行。

回答by Evgeniy Dorofeev

Try dependency:getlike this:

dependency:get像这样尝试:

mvn dependency:get -DrepoUrl=http://repo.maven.apache.org/maven2/ -Dartifact=org.springframework:spring-context:4.0.4.RELEASE:jar -Dtransitive=false -Ddest=spring-context-4.0.4.RELEASE.jar