最近下载使用了 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以下