原log为:
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 org.springframework:spring-web-reactive:jar:5.0.0.BUILD-20161108.121529-1 from/to archiva.internal (http://nexus.d.xiaomi.net/nexus/content/repositories/releases/): Failed to transfer file: http://nexus.d.xiaomi.net/nexus/content/repositories/releases/org/springframework/spring-web-reactive/5.0.0.BUILD-SNAPSHOT/spring-web-reactive-5.0.0.BUILD-20161108.121529-1.jar. Return code is: 400, ReasonPhrase: Bad Request.
使用mvn deploy发布到远程仓库时报错 Return code is: 400
可能出现这种的情况,原因有如下可能:
- 1.nexus的repository分三种类型:Hosted、 Proxy和Virtual,另外还有一个repository group(仓库组)用于对多个仓库进行组合。部署的时候只能部署到Hosted类型的仓库中,如果是其他类型就会出现这个400错误。
- 2.默认情况下部署构件到Releases仓库中有时也会出现400错误,这个原因就像上面提到的那样,Nexus中 Releases仓库默认的Deployment Policy是“Disable Redeploy”, 所以无论你在settings.xml文件中将server的username设置为deployment还是使用admin都是无 法部署的,就会出现这个400错误。
- 3.Nexus中 Releases仓库Respository PolicySnapshot是“Release” ,Snapshot仓库Respository PolicySnapshot是“Snapshot” 如果设置反了或错了也是无法部署的。
- 4.如果你Snapshot可以发布,但是releases却发布不了,可能是<version>1.0-SNAPSHOT</version>类似这样的,version中包含了-SNAPSHOT,所以release发布不了,也会返回400错误。
我的问题就是第四种情况导致,找到原因后,就deploy成功了。