Java - Maven私服不支持Https报错Since Maven 3.8.1 http repositories are blocked

10 篇文章 0 订阅

最近下载使用了 apache-maven-3.8.8,导致配置Maven的setting.xml文件之后报错如下:

Since Maven 3.8.1 http repositories are blocked.

Possible solutions:
- Check that Maven settings.xml does not contain http repositories
- Check that Maven pom files do not contain http repository http://xx1.com.cn/xx
- Check that Maven pom files do not contain http repository http://xx2.com.cn/xx
- Add a mirror(s) for http://xx1.com.cn/xx, http://xxw.com.cn/xx that allows http url in the Maven settings.xml
- Downgrade Maven to version 3.8.1 or earlier in settings

错误原因:

从Maven 3.8.1版本开始,出于安全原因,默认阻止了对HTTP仓库的访问,推荐使用HTTPS

错误信息表明Maven配置中包含了HTTP仓库地址

解决方法:

1、IDEA自带的Maven注释掉镜像maven-default-http-blocker(推荐)

在idea的安装目录plugins\maven\lib\maven3\conf下,找到setting.xml文件,注释掉镜像maven-default-http-blocker

将如下代码注释掉 ,因为Http开头的仓库都被这个 maven-default-http-blocker 拦截了,然后 blocked

    <mirror>
      <id>maven-default-http-blocker</id>
      <mirrorOf>external:http:*</mirrorOf>
      <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
      <url>http://0.0.0.0/</url>
      <blocked>true</blocked>
    </mirror>

2、升级Maven私有仓库为HTTPS

如果可能的话,将你的私有仓库和阿里云仓库升级为支持HTTPS协议,并在settings.xml文件中更新对应的URL。

<mirrors>    
	<mirror>        
		<id>your-mirror-id</id>        
		<name>Your Repository Name</name>        
		<url>https://192.168.1.1/repository/maven-public/</url>
		<!-- 使用HTTPS -->        
		<mirrorOf>*</mirrorOf>    
	</mirror>    
</mirrors>

3、暂时禁用HTTP检查

如果不方便立即升级为HTTPS,可以在Maven的settings.xml中添加全局配置来临时禁用HTTP检查

<settings>
	<profiles>
		<profile>
			<id>allow-http</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<properties>
				<maven.repo.http.protocol>http</maven.repo.http.protocol>
			</properties>
		</profile>
	</profiles>
	<activeProfiles>
		<activeProfile>allow-http</activeProfile>
	</activeProfiles>
</settings>

4、降低maven版本

将Maven降低到3.8.1以下

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值