场景

    在一个新环境(新电脑),第一次执行mvn package,很有可能出先类似问题,具体报错信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.222 s
[INFO] Finished at: 2018-08-18T14:54:25+08:00
[INFO] Final Memory: 8M/27M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_version -> [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/PluginResolutionException

原因

    这个问题还有另一种表现方式,在你请求国外的https网站的接口时,有可能会抛出以下异常:

1
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

    这都是因为你请求的网站不支持较低版本的协议。而你需要做的就是将请求的协议设置成它所支持的。你可以去下面网站查询你请求的网站支持的协议。

1
https://myssl.com

解决办法

maven打包是抛出这个异常

** 开发中遇到 **

  1. 在idea的Maven Projects 选项卡里右键 package,选择Create ‘XXXX’ [package]。
  2. 在弹出的窗口中,选择Runner里的VM Options中增加-Dhttps.protocols=TLSv1.2
    操作流程图
  3. 然后执行它。以后就不用执行了,可以正常的mvn clean package.
    操作流程图

** 部署时遇到 **
    如果你在部署中遇到这个问题,此时你只能使用命令,没有idea帮你做上面的事情,你修改$MAVEN_HOME/bin/mvn文件,在第一行添加MAVEN_OPTS=”-Dhttps.protocols=TLSv1.2”,打包好记得去掉。

请求https接口时抛出该异常

    去我的csdn看吧,有时间再搬过来。https://blog.csdn.net/gege87417376/article/details/77936507