分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

【原创】经验分享(10)Could not transfer artifact org.apache.maven:maven. from/to central. Received fatal alert: protocol_version

发布时间:2023-09-06 02:26责任编辑:沈小雨关键词:apache

maven编译工程报错

[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.2:add-source (scala-compile-first) on project trade: Execution scala-compile-first of goal net.alchim31.maven:scala-maven-plugin:3.2.2:add-source failed: Plugin net.alchim31.maven:scala-maven-plugin:3.2.2 or one of its dependencies could not be resolved: Failed to collect dependencies at net.alchim31.maven:scala-maven-plugin:jar:3.2.2 -> org.apache.maven:maven-core:jar:3.0.4 -> org.apache.maven:maven-model:jar:3.0.4: Failed to read artifact descriptor for org.apache.maven:maven-model:jar:3.0.4: Could not transfer artifact org.apache.maven:maven-model:pom:3.0.4 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

但是手工通过浏览器访问maven仓库一切正常

手工下载放到本地repository,然后再编译,这个错没了,又报下一个错,这么多包一个一个手工下载实在伤不起,

wtf,仔细一看,报错还有一句:Received fatal alert: protocol_version

原来是因为这个,官网地址:https://central.sonatype.org/articles/2018/May/04/discontinued-support-for-tlsv11-and-below/ 

这里粘贴一下answer:

If you are using http to access Central, or Java 8+ with https urls, you are not affected.

If you are on Java 7, it supports TLS 1.2 but it is disabled by default in versions before 1.7.0_131-b31, and the following Apache Maven workaround functions for older Java 7 users:

mvn -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2 <goals>

or add the following to your environment or build script:

export MAVEN_OPTS=-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2

If you are on Java 6, you will need to switch back to http or upgrade to a more modern Java version. Very recent versions of Java 6 claim to have TLS 1.2 support, but we have not confirmed it yet. 

原来是因为maven中央仓库不再支持TLSv1.1导致,jdk改为1.8问题解决。

【原创】经验分享(10)Could not transfer artifact org.apache.maven:maven. from/to central. Received fatal alert: protocol_version

原文地址:https://www.cnblogs.com/barneywill/p/10134845.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved