首页 > 解决方案 > 无法传输 http://repo.maven.apache.org/maven2 - 错误代码 501,需要 HTTPS

问题描述

我有一个虚拟机,我正在使用 spring 工具套件和 JDK7。

我已经从 git 下载了我的项目,但在 pom.xml 中出现错误:

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 (http://repo.maven.apache.org/maven2): 
Failed to transfer http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom. Error code 501, HTTPS Required 

小米pom.xml

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <compilerArgument>-Xlint:all</compilerArgument>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>

测试过。删除.m2,maven clean,...

我需要改变什么?

标签: javaeclipsemaven

解决方案


我相信错误正如它所说:它不支持未加密的请求。因此,我们应该将您的 URL 更改为 HTTPS。

https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom

如果由于某种原因您不能使用 HTTPS,请使用:

http://insecure.repo1.maven.org/maven2/

对于 Maven 存储库。

只是做了一个快速搜索,如果您想了解更多信息,可以找到一些参考资料:

Maven 依赖项因 501 错误而失败

由于您在阅读时遇到了一些问题,因此您需要更新您的 pom.xml 文件,我相信并更新您的 maven URL。它应该看起来像这样,或者使用类似的逻辑来使用上面的特定 URL 进行更新(如果没有您的 POM 文件部分,很难发布一个示例)。

<repositories>
  <repository>
    <id>central</id>
    <name>Central Repository</name>
    <url>https://repo.maven.apache.org/maven2</url>
    <layout>default</layout>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
</repositories>

推荐阅读