Java 收到致命警报:protocol_version 构建失败 Gradle/Maven
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51090914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Received fatal alert: protocol_version build failure Gradle/Maven
提问by Atul
One of my project's build started failing with the exception given below
我的项目构建之一开始失败,出现以下异常
> Could not resolve org.slf4j:slf4j-api:[1.6.1,).
> Failed to list versions for org.slf4j:slf4j-api.
> Unable to load Maven meta-data from https://repo1.maven.org/maven2/org/slf4j/slf4j-api/maven-metadata.xml.
> Could not GET 'https://repo1.maven.org/maven2/org/slf4j/slf4j-api/maven-metadata.xml'.
> Received fatal alert: protocol_version
Environment:
环境:
- Java 7
- Gradle 3.5
- 爪哇 7
- 摇篮 3.5
采纳答案by Atul
Maven Central and Bintray have announced that they will discontinue support for TLS v1.1 and below. You will be affected if you are using Java 6 or 7 and using Gradle versions 2.1 through 4.8.
Maven Central 和 Bintray 已宣布他们将停止对 TLS v1.1 及以下版本的支持。如果您使用的是 Java 6 或 7 以及 Gradle 版本 2.1 到 4.8,您将受到影响。
GRADLE:
等级:
Check gradle version
检查gradle版本
gradle --version
You must take action if all of these are true:
如果所有这些都属实,您必须采取行动:
- JVM version is Java 7u130 or lower and
- Gradle version is between 2.1 and 4.8, inclusive
- and you have declared a repository {} of mavenCentral() or jcenter()
- JVM 版本为 Java 7u130 或更低,并且
- Gradle 版本介于 2.1 和 4.8 之间,包括
- 并且您已经声明了 mavenCentral() 或 jcenter() 的存储库 {}
You can take any one of the following actions to use TLS v1.2+:
您可以采取以下任一操作来使用 TLS v1.2+:
- Run Gradle with Java 1.7.0_131-b31 or above
- or upgrade to Gradle 4.8.1 or above
- or replace mavenCentral() with maven { url = "http://repo.maven.apache.org/maven2" } and jcenter() with maven { url = "http://jcenter.bintray.com" }
- 使用 Java 1.7.0_131-b31 或更高版本运行 Gradle
- 或升级到 Gradle 4.8.1 或以上
- 或者用 maven { url = " http://repo.maven.apache.org/maven2" } 和 jcenter() 替换 mavenCentral() 用 maven { url = " http://jcenter.bintray.com" }
The first two solutions are recommended, as the third opens a possible attack vector.
推荐使用前两个解决方案,因为第三个打开了可能的攻击向量。
Source:https://blog.gradle.org
Maven:
马文:
如果您正在使用 MavenMaven使用下面给出的命令mvn -Dhttps.protocols=TLSv1.2 install
回答by George Vinokhodov
If you have similar problem with pom.xml - just update maven-compiler-plugin source and target version to 1.8, if possible.
如果您对 pom.xml 有类似问题 - 如果可能,只需将 maven-compiler-plugin 源和目标版本更新为 1.8。
回答by springified
IBM JDK
IBM JDK
if you are using IBM IDK you need to set following JVM argument.
如果您使用 IBM IDK,则需要设置以下 JVM 参数。
com.ibm.jsse2.overrideDefaultProtocol=SSL_TLSv2.
Refer the IBM documentation: https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/jsse2Docs/overrideSSLprotocol.html
请参阅 IBM 文档:https: //www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/jsse2Docs/overrideSSLprotocol.html
So, in eclipse IDE,
所以,在 Eclipse IDE 中,
Open 'Run->Run Configurations'; expand 'Gradle Project' and select the run configuration ( build )
打开“运行->运行配置”;展开“Gradle Project”并选择运行配置( build )
set the JVM argument as follows set jvm argument
如下设置JVM 参数 set jvm 参数