在发布工程开发版本,部署版本时,遇见两个问题,一个是配置setting.xml和工程pom.xml文件的server的ID名称一致性问题,第二个是发布部署版本时,nexus不允许同一版本重复部署,这个需要进行设置。先解决如下。
1.setting.xml中的server便签中的ID属性值必须和pom.xml中的 <distributionManagement> -》 <repository>下的ID保持一致,这是引导工程发布到nexus中的权限验证处理,如果不一致,会报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project *: Failed to deploy artifacts: Could not transfer artifact *:jar:1.0 from/to releases (http://10.1.81.199:8081/nexus/content/repositories/releases/): Failed to transfer file: http://10.1.81.199:8081/nexus/content/repositories/releases/com/cs2c/security-management-client* /1.0/*-1.0.jar. Return code is: 401, ReasonPhrase:Unauthorized.(在发布时未授权)
所以,这两处ID要保持一致。
2.默认情况下,nexus中部署版本不允许重复发布,但是有时候因为某些改动,变更,需要在本次版本发布,所以就要把解决该问题。否则,无法重复发布该版本。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7: deploy (default-deploy) on project First2: Failed to deploy artifacts: Could not transfer artifact com.myd.cn:First2:jar:1.0 from/to my-nexus-releases (http://127.0.0.1:8081/nexus/content/repositories/releases): Failed to transfer file: http://127.0.0.1:8081/nexus/content/repositories/releases/com/myd/cn/First2/1.0/First2-1.0.jar. Return code is: 400, ReasonPhrase: Bad Request. -> [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 [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn <goals> -rf :First2
所以,进入nexus的releases仓库,设置部署版本为允许重复发布。