Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven依赖项失败,出现501错误_Java_Maven_Jenkins_Maven Central - Fatal编程技术网

Java Maven依赖项失败,出现501错误

Java Maven依赖项失败,出现501错误,java,maven,jenkins,maven-central,Java,Maven,Jenkins,Maven Central,最近,在Jenkins中运行的Maven构建作业失败了,下面的异常表示它们无法从Maven Central提取依赖项,应该使用HTTPS。我不知道如何将请求从HTTP更改为HTTPS。有人能在这件事上指导我吗 [错误]无法解决的生成扩展: 插件org.apache.maven.wagen:wagen ssh:2.1或其依赖项之一无法解析: 未能收集org.apache.maven.wagon:wagon ssh:jar:2.1(): 未能读取org.apache.maven.wagen:wage

最近,在Jenkins中运行的Maven构建作业失败了,下面的异常表示它们无法从Maven Central提取依赖项,应该使用HTTPS。我不知道如何将请求从HTTP更改为HTTPS。有人能在这件事上指导我吗

[错误]无法解决的生成扩展:
插件
org.apache.maven.wagen:wagen ssh:2.1
或其依赖项之一无法解析:
未能收集
org.apache.maven.wagon:wagon ssh:jar:2.1()

未能读取
org.apache.maven.wagen:wagen ssh:jar:2.1的工件描述符:
无法将工件
org.apache.maven.wagg:wagg ssh:pom:2.1
从/传输到中心():
无法传输文件:。
返回代码为:
501,原因短语:需要HTTPS。->[帮助2]

等待Jenkins完成收集
数据[错误]

Plugin
org.apache.maven.plugins:maven clean Plugin:2.4.1
或其依赖项之一无法解析:
未能读取
org.apache.maven.plugins:maven clean plugin:jar:2.4.1

无法将工件
org.apache.maven.plugins:maven clean plugin:pom:2.4.1
从/传输到中心():
无法传输文件:。
返回代码为:
501,原因短语:需要HTTPS。->[帮助1]


尝试在任何浏览器中点击下面的URL。它将返回501

请尝试使用https。它将下载一个pom.xml文件:

<repositories>
   <repository>
      <id>Central Maven repository</id>
      <name>Central Maven repository https</name>
      <url>https://repo.maven.apache.org/maven2</url>
   </repository>
</repositories>

请将其()添加到setting.xml文件中:

<repositories>
   <repository>
      <id>Central Maven repository</id>
      <name>Central Maven repository https</name>
      <url>https://repo.maven.apache.org/maven2</url>
   </repository>
</repositories>

中央Maven存储库
中央Maven存储库https
https://repo.maven.apache.org/maven2
自2020年1月15日起生效,中央存储库不再支持 通过普通HTTP进行不安全的通信,并要求所有请求 通过HTTPS对存储库进行加密

如果收到此错误,则需要替换所有URL 对Maven Central及其规范HTTPS副本的引用

()

我们在我的项目的build.gradle中做了以下更改:

旧的:

新的:


观察到的误差的原因在中进行了解释

自2020年1月15日起生效,中央存储库不再支持 通过普通HTTP进行不安全的通信,并要求所有请求 通过HTTPS对存储库进行加密

看起来Maven的最新版本(在3.6.0和3.6.1中试用过)默认情况下已经在使用HTTPS URL

以下是主要存储库切换的日期:

更新:似乎maven 3.2.3中的maven central是通过HTTPS访问的 看

Maven更改日志
()

对于所有公司的编码人员,理想情况下, 如果您遇到这个错误,这意味着您的代码库仍然是从开源社区构建的。您需要与您的内部公司Maven repository manager一起超越“中心”存储库

您可以转到您的settings.xml并将您的中央存储库URL从http://覆盖到https://

<M2_HOME>/conf/settings.xml
/conf/settings.xml
查找“镜像”部分并添加以下条目:

    <mirror>
     <id>other-mirror</id>
     <name>Other Mirror Repository</name>
     <url>https://other-mirror.repo.other-company.com/maven2</url>
     <mirrorOf>central</mirrorOf>
    </mirror>

另一面镜子
其他镜像存储库
https://other-mirror.repo.other-company.com/maven2
中心的
在URL部分,如果您使用的是或,则

取代

取代

理想情况下,您需要在此处使用公司的源代码管理/存储库URL。因为这将阻止与开源Maven存储库社区的任何联系


如其他答案所述,自2020年1月15日起生效,Maven中央存储库不支持通过普通HTTP进行不安全的通信。

更新Maven中央存储库并使用https代替HTTP


中心的
中央知识库
https://repo.maven.apache.org/maven2
违约
假的

我使用的是过时的Maven版本(3.0.3和3.1)。这些旧版本不再支持http存储库(如上所述)。升级到Maven 3.6对我来说是一个解决方案。

在pom.xml中添加以下存储库


...
中心的
Maven插件库
https://repo1.maven.org/maven2
违约
假的
...

我在Docker容器上干净地安装了Maven/Java

<mirrors>
    <mirror>
        <id>https-mirror</id>
        <name>Https Mirror Repository</name>
        <url>https://repo1.maven.org/maven2</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
</mirrors>
对我来说,我必须
cd$M2_HOME/conf
并编辑那里的
settings.xml
文件。在


中央安全
https://repo.maven.apache.org/maven2
中心的

我也有同样的问题,但我使用了而不是Jenkins。为了克服这个问题,我必须采取以下步骤:

  • 我的项目在GitLab中,因此它使用.yml文件,该文件指向我必须进行连续集成的Docker映像,并且它使用的映像具有URL。所以我把它改成了
  • 同一个Dockerfile图像有一个Maven 3.0.1的旧版本,它在一夜之间给我带来了问题。我更新了Dockerfile以获得最新版本3.6.3
  • 然后,我将该映像部署到我的在线存储库中,并更新我的Maven项目ymlfile以使用该新映像
  • 最后,我将我的主要项目POM文件更新为引用..而不是
  • 我意识到这更具体于我的设置。但如果不执行上述所有步骤,我仍然会继续收到此错误消息
    返回代码为:501,原因短语:需要HTTPS

    简而言之,从2020年1月15日起,Maven中央存储库不再支持HTTP连接(其他存储库也在这样做)。因此,您将指示您的Maven/Gradle设置以使用HTTPS URL

    <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>
    <project>
    ...
        <repositories>
            <repository>
                <id>central</id>
                <name>Maven Plugin Repository</name>
                <url>https://repo1.maven.org/maven2</url>
                <layout>default</layout>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
        </repositories>
    ...
    </project>
    
    
    <mirror>
      <id>central-secure</id>
      <url>https://repo.maven.apache.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
    
    repositories {
       maven { url "https://repo.maven.apache.org/maven2" }
    }
    
    <project>
          ...
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <name>Central Repository</name>
                <url>https://repo.maven.apache.org/maven2</url>
                <layout>default</layout>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <releases>
                    <updatePolicy>never</updatePolicy>
                </releases>
            </pluginRepository>
        </pluginRepositories>
        <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>
    </project>
    
    <profile>
        <id>maven-https</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <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> 
    </profile>
    
    <mirrors>
        <mirror>
            <id>https-mirror</id>
            <name>Https Mirror Repository</name>
            <url>https://repo1.maven.org/maven2</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
    
    repositories {
    jcenter ()
    //others
    }
    
    repositories {
    jcenter { url "http://jcenter.bintray.com/"}
    //others
    }
    
    <mirrors>
        <mirror>
            <id>maven-mirror</id>
            <name>Maven Mirror</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
    
    repositories {
    google()
    jcenter()
    
    maven { url "http://dl.bintray.com/davideas/maven" }
    maven { url 'https://plugins.gradle.org/m2/' }
    maven { url 'http://repo1.maven.org/maven2' }
    maven { url 'http://jcenter.bintray.com' }
    }
    
    repositories {
    google()
    jcenter()
    
    maven { url "https://dl.bintray.com/davideas/maven" }
    maven { url 'https://plugins.gradle.org/m2/' }
    maven { url 'https://repo1.maven.org/maven2' }
    maven { url 'https://jcenter.bintray.com' }
    }
    
        <repositories>
           <repository>
              <id>Central Maven repository</id>
              <name>Central Maven repository insecure</name>
              <url>http://insecure.repo1.maven.org</url>
           </repository>
        </repositories>
    
      <repositories>
        <repository>
          <id>central</id>
          <name>Central Repository</name>
          <url>https://repo.maven.apache.org/maven2</url> <!-- the https you've been looking for -->
          <layout>default</layout>
          <snapshots>
            <enabled>false</enabled> <!-- or set to true if desired, default is false -->
          </snapshots>
        </repository>
      </repositories>
    
    <mirror>
    <id>maven-mirror</id>
    <name>Maven Mirror</name>
    <url>https://repo.maven.apache.org/maven2</url>
    <mirrorOf>central</mirrorOf>
    </mirror>
    
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    
    <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>
    
    Non-resolvable import POM: Could not transfer artifact org.springframework.cloud:spring-cloud-dependencies:pom:Hoxton.SR3 from/to central
    
    <repository>
                <id>maven_central_repo</id>
                <url>http://repo.maven.apache.org/maven2</url>
    </repository>
    
    <repository>
                <id>maven_central_repo</id>
                <url>https://repo.maven.apache.org/maven2</url>
    </repository>