Maven deploy报错
问题发现
deploy项目的正式版本到远程仓库报错,Return code is:400
报错信息
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project xxx: Failed to deploy artifacts: Could not transfer artifact xxx:jar:sources:x from/to xxx Failed to transfer file: xxx Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]
排查发现私服设置的是不能重复推送,所以如果私服存在相同版本的话是会报这个错误的。可是我在推之前上私服确定过不存在该版本的,为什么还会出现这个问题呢?
看构建日志发现,源码包被upload了两次,在第二次的时候就报了这个错误。
最后发现和maven的插件有关系。
解决
原来的插件是:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.5</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
修改为:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.5</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
修改完之后,再执行构建就不会upload两次了,就可以正常deploy到私服。
查看官网关于这个插件的介绍
http://maven.apache.org/plugins/maven-source-plugin/index.html