将第三方jar包提交私有仓库错误:400 Repository version policy: SNAPSHOT does not allow version: 1.1

  • 作者: 凯哥Java(公众号:凯哥Java)
  • 工作小总结
  • 时间:2024-01-30 17:26
  • 784人已阅读
简介 背景:在开发过程中,需要将第三方的jar提交的自己的私服仓库中。执行的命令:语法:mvndeploy:deploy-file -Dfile=jar全路径-DgroupId=groupId-DartifactId=artifactId-Dversion=版本-Dpackaging=jar-Durl=私服仓库地址 -DrepositoryId=snapshots实际应用例如:mvn

🔔🔔好消息!好消息!🔔🔔

 如果您需要注册ChatGPT,想要升级ChatGPT4。凯哥可以代注册ChatGPT账号代升级ChatGPT4

有需要的朋友👉:微信号 kaigejava2022

背景:

在开发过程中,需要将第三方的jar提交的自己的私服仓库中。执行的命令:

语法:

mvn deploy:deploy-file  -Dfile=jar全路径 -DgroupId=groupId -DartifactId=artifactId -Dversion=版本 -Dpackaging=jar -Durl=私服仓库地址  -DrepositoryId=snapshots

实际应用例如:

mvn deploy:deploy-file  -Dfile=C:\export\kaigejava.jar -DgroupId=com.kaigejava-DartifactId=my-test-jar  -Dversion=1.1 -Dpackaging=jar -Durl=http://192.168.1.1/repository/maven-snapshots/ -DrepositoryId=snapshots

执行后错误信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not transfer artifact com.isc:isc-sso-agent:jar:1.1 from/to snapshots (http://192.168.1.1/repository/maven-snapshots/): Transfer failed for http://192.168.1.1/repository/maven-snapshots/com/kaigejava/my-test-jar/1.1/kaigejava.jar 400 Repository version policy: SNAPSHOT does not allow version: 1.1 -> [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


错误原因:

根据错误信息,问题在于你试图将一个非SNAPSHOT版本(1.1)部署到你的Maven仓库中,但该仓库的策略只允许SNAPSHOT版本。400 Repository version policy: SNAPSHOT does not allow version: 1.1 这句明确指出了错误原因。

解决方法:

  1. 确认你的目标仓库是否只接受快照版本(SNAPSHOT)。如果是这样,你需要更改你的项目版本为SNAPSHOT版本,例如:1.1-SNAPSHOT

  2. 如果你确实要部署的是正式版(非SNAPSHOT),则需要检查并确认仓库配置,确保你正在使用的URL是用于发布正式版本的仓库地址,而非快照版本仓库地址。

所以,请根据实际情况调整如下命令中的 -Dversion 参数值:

mvn deploy:deploy-file  -Dfile=C:\export\kaigejava.jar -DgroupId=com.kaigejava-DartifactId=my-test-jar  -Dversion=1.1-SNAPSHOT -Dpackaging=jar -Durl=http://192.168.1.1/repository/maven-snapshots/ -DrepositoryId=snapshots

或者,如果你应该将正式版部署到另一个仓库,请更改 -Durl 参数指向正确的正式版仓库地址。



TopTop