代码之家  ›  专栏  ›  技术社区  ›  karans123

高效解决Maven移动构建中501 HTTPS必需错误(http://repo1.maven.org/maven2 & http://repo.spring.io)HTTPS?

  •  0
  • karans123  · 技术社区  · 5 年前

    需要 高效解决方案 为了迁移到HTTPS mvn clean install 建立成功

    我尝试了以下解决方案

    • 添加以下内容 settings.xml 在里面 ~/.m2/ 文件夹。还尝试了分析选项。

      <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>${user.home}/.m2/repository</localRepository>
            <interactiveMode/>
            <offline/>
            <pluginGroups/>
            <servers/>
                      <mirrors>
                           <mirror>
                            <id>central-repository</id>
                            <name>Maven Repository HTTPS</name>
                            <url>https://repo1.maven.org/maven2</url>
                            <mirrorOf>central</mirrorOf>
                          </mirror>
                           <mirror>
                            <id>central-spring-repository</id>
                            <name>Spring Repository HTTPS</name>
                            <url>https://repo.spring.io</url>
                            <mirrorOf>springcentral</mirrorOf>
                          </mirror>
                          <mirror>
                            <id>organisation-repo1</id>
                            <name>org-repo1</name>
                            <url>http://org.maven.com/repo1</url>
                            <mirrorOf>repo1</mirrorOf>
                          </mirror>
                          <mirror>
                            <id>organisation-repo2</id>
                            <name>org-repo2</name>
                            <url>http://org.maven.com/repo2</url>
                            <mirrorOf>repo2</mirrorOf>
                          </mirror>
                       </mirrors>
            <proxies/>
            <profiles/>
             <activeProfiles/>
      </settings>
      

    项目中的内部jar依赖关系仍然面临一些问题。

    未能读取的工件描述符 com.netflix.hystrix:hystrix核心:罐子:1.5.13:无法传输 artifact com.netflix.hystrix:hystrix核心:pom:1.5.13来自/来自cxf repo ( http://repo1.maven.org/maven2/ ):传输失败 http://repo1.maven.org/maven2/com/netflix/hystrix/hystrix-core/1.5.13/hystrix-core-1.5.13.pom 501需要HTTPS

    • 在以下内容中添加 pom.xml

            <repositories>
              <repository>
                  <id>central-maven</id>
                  <name>central https Releases</name>
                  <url>https://repo.maven.apache.org/maven2</url>
              </repository>
              <repository>
                  <id>central-spring</id>
                  <name>central spring https Releases</name>
                  <url>https://repo.spring.io</url>
              </repository>
            <repositories>
      

    已阅读此文档 maven中央仓库迁移到HTTPS https://blog.sonatype.com/central-repository-moving-to-https 但无法为内部依赖问题找到任何适当的解决方案。

    在我的例子中,一些依赖项仍然在调用central和spring的http url maven

    0 回复  |  直到 5 年前
        1
  •  3
  •   Shriram Prajapat    4 年前

    要么升级你的Maven版本 或

    通过修改POM来限制当前Maven版本使用HTTPS链接:

    在项目的pom.xml中包含以下代码。

    <project>
      ...
    <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>
    
        2
  •  0
  •   Sekhar T    4 年前

    备份.m2文件夹并进行清理和安装对我来说很有效。