maven: 解决 release to oss.sonatype.org 报错:SSL peer shut down incorrectly

今天执行mvn release:perform发布项目jar包到maven中央仓库时报了如下错误导致发布失败:

Remote host terminated the handshake
SSL peer shut down incorrectly

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project common-base: Failed to deploy metadata: Could not transfer metadata com.gitee.l0km:common-base/maven-metadata.xml from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Remote host closed connection during handshake: SSL peer shut down incorrectly -> [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  -rf :common-base

出现这个情况并是必然的,目前没有找到规律,好像发布比较大的jar出现的概率就大一些。有时失败后重新执行一遍又能正常通过。所以就没在意,但是今天发布一个超过100MB的jar包时,执行了5,6次都报如上的错误就不能忍了。
google上搜索了一相关的主题,发现好像是ssl的问题:

比如这个mave官方的说明:
https://issues.sonatype.org/browse/NEXUS-7659
maven: 解决 release to oss.sonatype.org 报错:SSL peer shut down incorrectly_第1张图片
再比如这个stackoverflow上的帖子给出了解决方案,如下图:
https://stackoverflow.com/questions/50328668/maven-java-build-ssl-peer-shut-down-incorrectly

maven: 解决 release to oss.sonatype.org 报错:SSL peer shut down incorrectly_第2张图片
对你没看错, 上图红框圈出来的就是解决方案,如下执行release就可以了:

mvn release:perform -Dhttps.protocols=TLSv1.2

经实测,如果发布版本时遇到SSL peer shut down incorrectly的问题,就上加-Dhttps.protocols=TLSv1.2参数再执行一次,应该就可以成功发布了。

你可能感兴趣的:(java,开发工具,maven,ssl,release,perform)