大家在下载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的源码去变异文章来源:https://www.toymoban.com/news/detail-478694.html
试了很多种办法,普通用户没有办法注册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文章来源地址https://www.toymoban.com/news/detail-478694.html
到了这里,关于Gradle下载spring包出现Received status code 401 from server: Unauthorized的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!