关于maven打包时的报错:http://repo.maven.apache.org/maven2/ Return code is: 501

最近本地打包一直报以下错误

Could not transfer artifact xxxx from/to central (http://repo1.maven.org/maven2/):Failed to transfer file:http://repo1.maven.org/maven2/xxxxx. Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]

  我们发现,这个依赖的文件在本地仓库是有的,但是在构建过程中,在本地nexus下载完文件后,还是会像中央仓库请求文件下载

  Downloading from central: http://repo1.maven.org/maven2/ssss

  之后我们根据返回的501错误,去搜索问题,参考链接如下:

  https://stackoverflow.com/questions/59763531/maven-dependencies-are-failing-with-501-error

     上面提示,自2020年1月15日起,中央存储库不再支持通过纯HTTP进行的不安全通信,并且要求对存储库的所有请求都通过HTTPS进行加密。

解决办法1:

在构建过程中所依赖的settings文件中,加入了以下配置:

1

2

3

4

5

6

<mirror>

<id>central</id>

<name>Maven Repository Switchboard</name>

<url>https://repo1.maven.org/maven2/</url>

<mirrorOf>central</mirrorOf>

</mirror>

解决办法2:

在项目pom.xml中添加如下配置:

<repositories>
    <repository>
        <id>central</id>
        <url>https://repo1.maven.org/maven2/</url>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>central</id>
        <url>https://repo1.maven.org/maven2/</url>
    </pluginRepository>
</pluginRepositories>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值