Gradle下载spring包出现Received status code 401 from server: Unauthorized

大家在下载spring家族源码的时候,在进行gradle构建的时候,会出现y:

Could not GET 'https://repo.spring.io/libs-release/xxxxx'. Received status code 401 from server: Unauthorized
Disable Gradle 'offline mode' and sync project

这个原因是spring从2021.2.21日开始不再支持匿名用户访问/libs-release的目录了。

We will no longer support anonymous download of 3rd-party Maven Central artifacts from repo.spring.io, even if previously cached by an authenticated user. They should be resolved instead from the central servers.

几种解决方法:

  • 如果是/libs-snapshot 或者 /libs-milestone,需要修改为/snapshot 或者 /milestone

  • 或者讲repository改为阿里云的仓库地址c

        //本地仓库,地址是maven本地仓库路径
        mavenLocal()
        //maven私服。此处设置为ali的旧库,地址是url
        maven{ url "http://maven.aliyun.com/nexus/content/groups/public" }
        //阿里云新库
        maven { url "https://maven.aliyun.com/repository/central" }
        maven { url "https://maven.aliyun.com/repository/google" }
        maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
        maven { url "https://maven.aliyun.com/repository/jcenter" }
        maven { url "https://maven.aliyun.com/repository/spring" }
        maven { url "https://maven.aliyun.com/repository/spring-plugin" }
        maven { url "https://maven.aliyun.com/repository/public" }
        maven { url "https://maven.aliyun.com/repository/releases" }
        maven { url "https://maven.aliyun.com/repository/snapshots" }
        maven { url "https://maven.aliyun.com/repository/grails-core" }
        maven { url "https://maven.aliyun.com/repository/mapr-public" }
        maven { url "https://maven.aliyun.com/repository/apache-snapshots" }
  • 如果阿里云仓库里面没有,IDE还在报401的错误,也就是几乎没有办法下载到依赖的。需要找相关spring家族源码的更高版本。比如:我找的是spring-session2.1.2一直有这个问题,下载2.7.x的源码去变异

试了很多种办法,普通用户没有办法注册repos.spring.io的账号的。所以如果想通过manve中指定账号和密码的方法比较困难。

更多信息详见spring官方文档y:https://spring.io/blog/2020/10/29/notice-of-permissions-changes-to-repo-spring-io-fall-and-winter-2020

  • 11
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值