首页 > 解决方案 > 如何通过 https 在 maven 上获取 pom标签?

问题描述

我尝试通过源代码在我的电脑上安装 Apache Ignite 2.9.1(最新版本)。

我需要在其中运行

mvn clean install -Pall-java,all-scala,licenses -DskipTests

但是,有一个错误,我无法从 maven 存储库中获取 pom 文件。

Downloading from repo1: http://repo1.maven.org/maven2/org/apache/apache/16/apache-16.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'parent.relativePath' of POM org.apache.ignite:ignite-parent:1 (E:\Ignite\apache-ignite-2.9.1-src\apache-ignite-2.9.1-src\parent\pom.xml) points at org.apache.ignite:apache-ignite instead of org.apache:apache, please verify your project structure @ org.apache.ignite:ignite-parent:1, E:\Ignite\apache-ignite-2.9.1-src\apache-ignite-2.9.1-src\parent\pom.xml, line 29, column 13
[FATAL] Non-resolvable parent POM for org.apache.ignite:ignite-parent:1: Could not transfer artifact org.apache:apache:pom:16 from/to repo1 (http://repo1.maven.org/maven2/): Transfer failed for http://repo1.maven.org/maven2/org/apache/apache/16/apache-16.pom 501 HTTPS Required and 'parent.relativePath' points at wrong local POM @ org.apache.ignite:ignite-parent:1, E:\Ignite\apache-ignite-2.9.1-src\apache-ignite-2.9.1-src\parent\pom.xml, line 29, column 13
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project org.apache.ignite:apache-ignite:2.9.1 (E:\Ignite\apache-ignite-2.9.1-src\apache-ignite-2.9.1-src\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for org.apache.ignite:ignite-parent:1: Could not transfer artifact org.apache:apache:pom:16 from/to repo1 (http://repo1.maven.org/maven2/): Transfer failed for http://repo1.maven.org/maven2/org/apache/apache/16/apache-16.pom 501 HTTPS Required and 'parent.relativePath' points at wrong local POM @ org.apache.ignite:ignite-parent:1, E:\Ignite\apache-ignite-2.9.1-src\apache-ignite-2.9.1-src\parent\pom.xml, line 29, column 13 -> [Help 2]
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

这是因为maven已经把所有的http都转成https了,所以我应该使用 https://repo1.maven.org/maven2/org/apache/apache/16/apache-16.pom 而不是 http://repo1.maven.org/maven2/org/apache/apache/16/apache-16.pom

但是当我在 Ignite 文件夹中找到 pom.xml 时,我发现它是:

<parent>
        <groupId>org.apache</groupId>
        <artifactId>apache</artifactId>
        <version>16</version>
</parent>

我无法获取的 pom 文件由 <parent> 标记声明。

那么,我怎样才能转移 url 来下载这个 pom?另外,在一些老的maven项目中经常有很多http url(dependences, pom, ...),有什么工具可以自动把这些http url转成https吗?

另外,我的 Maven 版本是 3.6.3,我的 {MAVEN_HOME}/conf/setting.xml 是

<mirrors>
     <mirror>
        <id>alimaven</id>
        <name>aliyun maven</name>
        <url>https://maven.aliyun.com/nexus/content/groups/public/</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>

<profile>
    <id>maven-https</id>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
    <repositories>
        <repository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories> 
</profile>

标签: mavenignite

解决方案


看来这个问题已经部分回答了。很可能你有一个过时的 Maven 版本(< 3.2.3)。这就是为什么您的构建试图达到http://repo1.maven.org/maven2/. 查看描述此行为的文章。您的设置解决方法可能不起作用,因为http://repo1.maven.org/maven2/它曾经是 Maven 3.0.4 之前的默认设置,但您https://repo.maven.apache.org/maven2settings.xml. 是证实这一点的答案。据我了解,您有 3 个基本选项:

  • 将 Maven 更新到一些较新的版本 (3.2.3+)
  • 更改pom.xml以反映正确的端点
<repositories>
    <repository>
        <id>central</id>
        <url>https://repo1.maven.org/maven2/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>central</id>
        <url>https://repo1.maven.org/maven2/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>
  • 修改settings.xml以包含适当的镜像
<mirrors>
    <mirror>
        <id>centralhttps</id>
        <mirrorOf>central</mirrorOf>
        <name>Maven central https</name>
        <url>https://repo1.maven.org/maven2/</url>
    </mirror>
</mirrors>

推荐阅读