无法传输工件(https://repo.maven.apache.org/maven2):收到致命警报:protocol_version-> [Help 1]

时间:2018-06-20 10:48:25

标签: java maven

我是Maven的新手,尝试在Maven中设置我的第一个项目,但是在Eclipse中执行“ Run as-> Maven install”时收到以下错误消息。下面是我的settings.xml和pom.xml

Settings.xml

    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
 <localRepository>C:\Users\Iam\.m2\repository</localRepository>
  <profiles>
    <profile>
      <repositories>
    <repository>
        <id>central</id>
        <url>http://central.maven.org/maven2/</url>
        </repository>
    </repositories>
      <pluginRepositories>
      </pluginRepositories>
    </profile>
  </profiles>
</settings>

POM.XML

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
  <groupId>com.mytest</groupId> 
  <artifactId>MySpringBootMaven</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.11.RELEASE</version>
    </parent>


<build>
    <plugins>

      <plugin>
        <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>


        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.5</version><!--$NO-MVN-MAN-VER$-->
                <configuration>
                    <warnName>Test.war</warnName>
                </configuration>
            </plugin>
    </plugins>

</build>
</project>

错误消息:

at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.springframework.boot:spring-boot-maven-plugin:jar:1.5.11.RELEASE
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:302)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:218)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:287)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:103)
    ... 27 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.springframework.boot:spring-boot-maven-plugin:pom:1.5.11.RELEASE from/to central (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_version
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:287)
    ... 30 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.springframework.boot:spring-boot-maven-plugin:pom:1.5.11.RELEASE from/to central (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_version

如何解决收到的致命警报:protocol_version?我的Java版本是1.7,maven版本是3.3.3

10 个答案:

答案 0 :(得分:63)

Sonatype no longer supports TLSv1.1 and below(于2018年6月18日生效)。我的猜测是您使用的是TLSv1.1协议或更低版本。

我列出的文档为您提供了4种选择:

  1. 例如使用OpenJDK构建或Oracle付费支持来升级Java运行时
  2. 通过添加-Dhttps.protocols = TLSv1.2,将Java运行时配置为启用TLS 1.2
  3. 使用使用支持TLS 1.2的Java版本的存储库管理器
  4. 返回到http,直到您可以完成上述补救措施之一。

我自己通过使用-Dhttps.protocols = TLSv1.2作为VM参数来修复了它。

答案 1 :(得分:7)

对于永久解决方案(在Java 7中通常是必需的)-在构建目录(从中执行mvn命令的位置)中添加目录:

.mvn(以cmd mkdir .mvn为单位)

并在其中创建文件

jvm.config

并输入以下行:

-Dhttps.protocols=TLSv1.2

答案 2 :(得分:4)

最简单的解决方案是配置JVM运行时参数。在eclipse上,您可以按照以下步骤进行操作:

转到Windows> preferences> java>已安装的JRE 单击您用于项目的已安装JRE / JDK

点击右侧的“编辑”, 并在“默认VM参数输入”字段中添加-Dhttps.protocols=TLSv1.2

查看屏幕截图:

Screenshot

答案 3 :(得分:4)

您要安装的软件包不支持TLS1.1 ,默认情况下,您可能会使用TLS 1.1。通过在Maven Build命令中添加-Dhttps.protocols=TLSv1.2,将Java运行时配置为启用TLS 1.2,即可解决此问题。

例如:mvn clean install -Dhttps.protocols=TLSv1.2

答案 4 :(得分:3)

我已经从Java 1.7升级到Java 1.8,并得到了相同的错误。 要解决此错误,我使用<U> CompletionStage<U> thenApplyAsync​(Function<? super T,​? extends U> fn, Executor executor) 检查了mvn版本,发现JAVA_HOME仍在使用Java 1.7。我将环境变量中的JAVA_HOME更改为指向JDK中的Java 1.8 jre

希望这对某人有帮助。

答案 5 :(得分:2)

我在.m2目录中设置我的 settings.xml 文件,就像在这里设置的那样:https://github.com/alipay/sofa-rpc/pull/190/files

然后执行mvn install,所有依赖项开始下载。我之前没有settings.xml文件,并且没有使用任何代理。 希望它能帮助到别人。

PD。我有jdk 1.7和Maven 3.3.9

答案 6 :(得分:0)

它同时需要两个:配置JVM运行时参数以及具有settings.xml,在我都完成之后。仅更新JVM运行时参数无济于事。

答案 7 :(得分:0)

我通过在settings.xml驱动器的Users文件夹中的.m2文件夹中添加C文件并通过更新Project来解决了 SpringToolSuit 中的此错误。 右键点击pom.xml -> Maeven -> Update Project

确保选择“强制更新snapshots/releases”。

答案 8 :(得分:0)

在我的情况下,Eclipse中禁用了Maven依赖项的自动更新。
解决方案:
去 Windows->首选项-> Maven
并取消选中复选框

不要自动更新远程存储库中的依赖项

然后更新项目
右键单击project-> maven-> update project

答案 9 :(得分:0)

我遇到了同样的问题,我在这里尝试了大部分答案,但仍然无效。我的问题是我的 IDE 上的代理设置。所以记住检查代理设置也很重要。文件 > 设置 > 系统设置 > HTTP 代理 - 选择自动检测代理设置