具体的错误信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project parent: Failed to deploy artifacts: Could not transfer artifact com.xx.yyy:parent:pom:2.0 from/to releases (http://nexus.zzzz.net/repository/
maven-releases/): Failed to transfer file: http://nexus.zzzz.net/repository/maven-releases/com/xx/yyyy/parent/2.0/parent-2.0.pom. Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]

查看 nexus 日志,发现了这么一行:

user org.sonatype.nexus.repository.view.handlers.ExceptionHandler - Illegal operation: PUT /com/xx/yyy/parent/2.0/parent-2.0.pom: org.sonatype.nexus.repository.IllegalOperationException: Repository does not allow updating assets: maven-releases

原来是这个仓库禁止对包进行更新。用管理员登录  nexus, 找到 maven-releases 这个仓库,发现其中一个设置:

mvn deploy 到 nexus,报错 Return code is: 400, ReasonPhrase: Bad Request

 

 

 把它改成 Allow redeploy,再尝试 mvn deploy 就没问题了。

 

为什么要设置成 Disable redeploy?

因为 maven-releases 这个仓库存放的是正式包而非 snapshot. 也就意味着,你需要部署精心测试过的版本。如果允许更新部署,那么已经拉取了这个版本的用户将无法得知更新的通知,导致本地仓库的版本和远端仓库不一样。如果你的更新中包含了重大的 bug 修复,你认为已经修复了问题,用户还有可能将有问题的版本部署出去而无法得知。

所以设置 Disable redeploy 是合理的,而且不应该修改这个参数。

如果有小的 bug 修复或优化,应该使用新的版本号,这时候可以使用版本号中的第三段,如 2.0.x.

 

SNAPSHOT 的版本是可以被覆盖的,看一下 snapshot 仓库的设置是 Allow redeploy.

 

相关文章:

  • 2021-09-14
  • 2022-12-23
  • 2022-01-14
  • 2019-02-21
  • 2021-07-12
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-09
  • 2022-12-23
  • 2021-05-26
  • 2021-11-22
  • 2021-10-19
相关资源
相似解决方案