xxx.jar‘. Received status code 401 from server: Unauthorized
背景
- gradle下载依赖时报一堆的
Received status code 401 from server: Unauthorized
问题,具体异常如下所示。
<ij_msg_gr>Project resolve errors<ij_msg_gr><ij_nav>D:\work\self\spring-framework-5.0.8.RELEASE\build.gradle<ij_nav><i><b>root project 'spring': Unable to resolve additional project configuration.</b><eol>Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':testCompileClasspath'.<eol>Caused by: org.gradle.internal.resolve.ArtifactResolveException: Could not download aspectjweaver.jar (org.aspectj:aspectjweaver:1.8.13)<eol>Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'.<eol>Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'. Received status code 401 from server: Unauthorized</i>
The getTestClassesDir() method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the getTestClassesDirs() method instead.
<ij_msg_gr>Project resolve errors<ij_msg_gr><ij_nav>D:\work\self\spring-framework-5.0.8.RELEASE\build.gradle<ij_nav><i><b>root project 'spring': Unable to resolve additional project configuration.</b><eol>Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':testCompileClasspath'.<eol>Caused by: org.gradle.internal.resolve.ArtifactResolveException: Could not download aspectjweaver.jar (org.aspectj:aspectjweaver:1.8.13)<eol>Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'.<eol>Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'. Received status code 401 from server: Unauthorized</i>
<ij_msg_gr>Project resolve errors<ij_msg_gr><ij_nav>D:\work\self\spring-framework-5.0.8.RELEASE\spring-aop\spring-aop.gradle<ij_nav><i><b>project ':spring-aop': Unable to resolve additional project configuration.</b><eol>Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':spring-aop:optional'.<eol>Caused by: org.gradle.internal.resolve.ArtifactResolveException: Could not download aspectjweaver.jar (org.aspectj:aspectjweaver:1.8.13)<eol>Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'.<eol>Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'. Received status code 401 from server: Unauthorized</i>
<ij_msg_gr>Project resolve errors<ij_msg_gr><ij_nav>D:\work\self\spring-framework-5.0.8.RELEASE\spring-aspects\spring-aspects.gradle<ij_nav><i><b>project ':spring-aspects': Unable to resolve additional project configuration.</b><eol>Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':spring-aspects:compileClasspath'.<eol>Caused by: org.gradle.internal.resolve.ArtifactResolveException: Could not download aspectjweaver.jar (org.aspectj:aspectjweaver:1.8.13)<eol>Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'.<eol>Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'. Received status code 401 from server: Unauthorized</i>
<ij_msg_gr>Project resolve errors<ij_msg_gr><ij_nav>D:\work\self\spring-framework-5.0.8.RELEASE\spring-context\spring-context.gradle<ij_nav><i><b>project ':spring-context': Unable to resolve additional project configuration.</b><eol>Details: org.gradle.internal.resolve.ArtifactResolveException: Could not download aspectjweaver.jar (org.aspectj:aspectjweaver:1.8.13)<eol>Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'.<eol>Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'. Received status code 401 from server: Unauthorized</i>
<ij_msg_gr>Project resolve errors<ij_msg_gr><ij_nav>D:\work\self\spring-framework-5.0.8.RELEASE\spring-core\spring-core.gradle<ij_nav><i><b>project ':spring-core': Unable to resolve additional project configuration.</b><eol>Details: org.gradle.internal.resolve.ArtifactResolveException: Could not download aspectjweaver.jar (org.aspectj:aspectjweaver:1.8.13)<eol>Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'.<eol>Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'. Received status code 401 from server: Unauthorized</i>
<ij_msg_gr>Project resolve errors<ij_msg_gr><ij_nav>D:\work\self\spring-framework-5.0.8.RELEASE\spring-orm\spring-orm.gradle<ij_nav><i><b>project ':spring-orm': Unable to resolve additional project configuration.</b><eol>Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':spring-orm:testCompileClasspath'.<eol>Caused by: org.gradle.internal.resolve.ArtifactResolveException: Could not download aspectjweaver.jar (org.aspectj:aspectjweaver:1.8.13)<eol>Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'.<eol>Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'. Received status code 401 from server: Unauthorized</i>
<ij_msg_gr>Project resolve errors<ij_msg_gr><ij_nav>D:\work\self\spring-framework-5.0.8.RELEASE\spring-test\spring-test.gradle<ij_nav><i><b>project ':spring-test': Unable to resolve additional project configuration.</b><eol>Details: org.gradle.internal.resolve.ArtifactResolveException: Could not download aspectjweaver.jar (org.aspectj:aspectjweaver:1.8.13)<eol>Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'.<eol>Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'. Received status code 401 from server: Unauthorized</i>
<ij_msg_gr>Project resolve errors<ij_msg_gr><ij_nav>D:\work\self\spring-framework-5.0.8.RELEASE\spring-tx\spring-tx.gradle<ij_nav><i><b>project ':spring-tx': Unable to resolve additional project configuration.</b><eol>Details: org.gradle.internal.resolve.ArtifactResolveException: Could not download aspectjweaver.jar (org.aspectj:aspectjweaver:1.8.13)<eol>Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'.<eol>Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not HEAD 'https://repo.spring.io/libs-release/org/aspectj/aspectjweaver/1.8.13/aspectjweaver-1.8.13.jar'. Received status code 401 from server: Unauthorized</i>
- 未认证的问题,于是打开链接,看看是什么鬼。
- 看到上图,原因已经找到了,不知道从什么时候开始,从spring的仓库下载东西居然要认证了。
解决方案
-
更换仓库地址。
-
我这里换成了阿里云的maven仓库:把之前的
https://repo.spring.io/libs-release
值替换为https://maven.aliyun.com/repository/public
。如下图所示。
-
更换后就完成了,再次重新导入就不会报错了,如下所示。
-
另外如果还有包的问题可以参考下,下篇文章Could not resolve: com.ibm.websphere:uow:6.0.2.17