1.错误发生的场景:eclipse 项目运行 maven install ,报错了
2.错误的主要描述: Failed to execute goal org.apache.maven.plugins:maven-install-plugin:
2.4:install (default-install) on project TENDJ:
Execution default-install of goal org.apache.maven.plugins:maven-install-plugin:2.4:
install failed: Plugin org.apache.maven.plugins:maven-install-plugin:
2.4 or one of its dependencies could not be resolved:
Failed to collect dependencies at org.apache.maven.plugins:maven-install-plugin:jar:2.4 ->
org.codehaus.plexus:plexus-utils:jar:3.0.5: Failed to read artifact descriptor for org.codehaus.plexus:plexus-utils:jar:3.0.5:
Could not transfer artifact org.codehaus.plexus:plexus-utils:pom:3.0.5 from/to central (https://repo.maven.apache.org/maven2):
Received fatal alert: protocol_version -> [Help 1]
3.根据翻译来说,主要是最后面这个问题,protocol_version 也就是协议版本的错误,于是上网查找到了对应的原因 maven Sonatype 中央仓库目前不再支持 TLSv1.1 以及以下的协议版本,通过chrome security 面板看到, 我自己使用的maven 中央仓库已经是 TLSv1.2 协议了
4.解决办法:
4.1.使用http去访问maven中央仓库(适用于对安全不严格的场景),修改setting.xml文件
<profiles>
<profile>
<id>maven-home</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
</profile>
4.2.升级jdk到1.8
4.3.通过添加 -Dhttps.protocols=TLSv1.2 , 配置 java runtime 参数,来 enable TLS 1.2
我用的就是第三种方法:
找到eclipse的jdk配置环境,在"Default VM arguments"这一栏填入:-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
参考文章:
https://feitianbenyue.iteye.com/blog/2429045
https://www.cnblogs.com/leite/p/9865961.html