使用Maven Deploy项目到Nexus时报错: Return code is: 400, ReasonPhrase: Bad Request

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Alexshi5/article/details/81633948

一、问题描述

今天在使用Maven命令:mvn deploy将项目部署到nexus中时报错如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project maibao-parent: Failed to deploy artifacts: Could not transfer artifact com.mengfei:maibao-parent:pom:1.0-20180813.091645-1 from/to reployToNexus-snapshots (http://192.168.188.132:8081/nexus/content/groups/public): Failed to transfer file: http://192.168.188.132:8081/nexus/content/groups/public/com/mengfei/maibao-parent/1.0-SNAPSHOT/maibao-parent-1.0-20180813.091645-1.pom. Return code is: 400, ReasonPhrase: Bad Request.

二、问题原因

        部署的仓库类型错误、部署的仓库部署策略为禁止部署或者部署的仓库发布版本与部署的项目发布版本不相符等都会导致出现这个错误。

三、解决问题

1、部署的仓库类型错误

        nexus的repository分三种类型:Hosted、 Proxy和Virtual,另外还有一个repository group(仓库组)用于对多个仓库进行组合,部署的时候只能部署到Hosted类型的仓库中。

2、部署的仓库部署策略为禁止部署

releases仓库的部署策略默认为禁止部署,如果要部署到这个仓库中需要修改部署策略为Allow Redeploy

3、仓库发布版本与部署的项目发布版本不相符

项目的发布版本如果为<version>1.0-SNAPSHOT</version>,则不能部署到发布版本为Release的仓库中

Snapshots仓库也是一样,不能部署版本为Release的项目 

参考:https://blog.csdn.net/running_snail_/article/details/19821777

猜你喜欢

转载自blog.csdn.net/Alexshi5/article/details/81633948