maven仓库报错:501 HTTPS Required

486 阅读1分钟

之前项目中的settings配置一直使用的阿里云的镜像地址,只是阿里云的有不少需要的依赖没有,就增加了mirror。

	<mirror>
		<id>repo1</id>
		<mirrorOf>central</mirrorOf>
		<name>Human Readable Name for this Mirror.</name>
		<url>http://repo1.maven.org/maven2/</url>
	</mirror>

直接报错:

501 HTTPS Required

意思是需要HTTPS协议才行。

在浏览器输入:

repo1.maven.org/maven2

直接提示:

501 HTTPS Required. 
Use https://repo1.maven.org/maven2/
More information at https://links.sonatype.com/central/501-https-required

 这就很明白了,为了安全起见,现在很多http的请求都改成了HTTPS。我们修改上面的pom依赖:

	<mirror>
		<id>repo1</id>
		<mirrorOf>central</mirrorOf>
		<name>Human Readable Name for this Mirror.</name>
		<url>https://repo1.maven.org/maven2/</url>
	</mirror>

这样就正确了。不过在idea上可能还会报错,可能的原因就是要修改一下idea的配置了。

 加上一句配置即可:

-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

 意思是让maven忽略SSL证书校验。此时就可以正常加载jar包和依赖了。