java-使用命令行从Nexus下载具有依赖项的Maven工件
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java-使用命令行从Nexus下载具有依赖项的Maven工件,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3542字,纯文字阅读大概需要6分钟。
内容图文
![java-使用命令行从Nexus下载具有依赖项的Maven工件](/upload/InfoBanner/zyjiaocheng/665/47542ffd73ad4c3b934d111c6f5cd5b0.jpg)
我正在使用以下命令通过命令行从Nexus下载Maven jar.
call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=http://10.101.15.190:8081/nexus/content/repositories/releases/ -Dartifact=bits:update-service:1.0.3 -Ddest=Setups/Services/update-service.jar
但是我得到的是一个没有依赖性的罐子. Maven中已经有一个带有依赖项的jar,其名称为update-service-1.0.4-jar-with-dependencies.jar
我尝试了以下方法:
call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=http://10.101.15.190:8081/nexus/content/repositories/releases/ -Dartifact=bits:update-service:1.0.3[:packaging[:jar]] -Ddest=Setups/Services/update-service.jar
但它返回以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.4:get (default-cli) on project standalone-pom: Couldn't download artifact: Missing:
[ERROR] ----------
[ERROR] 1) bits:update-service:packaging[:jar]]:1.0.3[
[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=bits -DartifactId=update-service -Dversion=1.0.3[ -Dclassifier=jar]] -Dpackaging=packaging[ -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=bits -DartifactId=update-service -Dversion=1.0.3[ -Dclassifier=jar]] -Dpackaging=packaging[ -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) bits:update-service:packaging[:jar]]:1.0.3[
[ERROR]
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR]
[ERROR] for artifact:
[ERROR] org.apache.maven.plugins:maven-downloader-plugin:jar:1.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false),
[ERROR] temp (http://10.101.15.190:8081/nexus/content/repositories/releases/, releases=true, snapshots=true)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
问题:下载具有依赖项的jar的正确方法是什么?
解决方法:
在这种情况下,jar-with-dependencies是Maven classifier:
The classifier allows to distinguish artifacts that were built from the same POM but differ in their content. It is some optional and arbitrary string that – if present – is appended to the artifact name just after the version number.
也就是说,1.0.4 jar及其with-dependencies变体通过分类器的Maven坐标有所不同.
因此,使用maven-dependency-plugin及其get目标,您可以通过classifier选项指定分类器:
The classifier of the artifact to download. Ignored if
artifact
is used.
但是,您确实已经在使用artifact选项,因此根据文档,上述选项将被忽略.
但是,如果您查看工件选项的文档:
A string of the form
groupId:artifactId:version[:packaging][:classifier]
.
查看其最后一个(可选)标记[:classifier].这正是您所缺少的.
您的工件选项应如下所示:
-Dartifact=bits:update-service:1.0.4:jar:jar-with-dependencies
注意:您在指定时实际上已经错误地使用了它:
-Dartifact=bits:update-service:1.0.3[:packaging[:jar]]
方括号[..]表示可选参数,不应在命令行调用中指定它们.此外,那里的包装字符串指定要放置的值:同样,您不应指定它,而应将其替换为相应的值(在本例中为jar).
内容总结
以上是互联网集市为您收集整理的java-使用命令行从Nexus下载具有依赖项的Maven工件全部内容,希望文章能够帮你解决java-使用命令行从Nexus下载具有依赖项的Maven工件所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。