如何关闭maven-default-http-blocker?

简介: 解决报错 Could not validate integrity of download from http://0.0.0.0/

最近升级Maven到3.8.1后,mvn编译的时候总是提示拉不到依赖,报错如下:

Could not validate integrity of download from http://0.0.0.0/...

全部报错如下:

[WARNING] Could not validate integrity of download from http://0.0.0.0/com/alibaba/nacos/nacos-client-mse-extension/1.4.2-SNAPSHOT/maven-metadata.xml
org.eclipse.aether.transfer.ChecksumFailureException: Checksum validation failed, expected <!doctype but is 18420d7f1430a348837b97a31a80e374e3b00254
    at org.eclipse.aether.connector.basic.ChecksumValidator.validateExternalChecksums (ChecksumValidator.java:174)
    at org.eclipse.aether.connector.basic.ChecksumValidator.validate (ChecksumValidator.java:103)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask (BasicRepositoryConnector.java:460)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:364)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute (BasicRepositoryConnector.java:628)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get (BasicRepositoryConnector.java:235)
    at org.eclipse.aether.internal.impl.DefaultMetadataResolver$ResolveTask.run (DefaultMetadataResolver.java:573)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:630)
    at java.lang.Thread.run (Thread.java:832)
[WARNING] Checksum validation failed, expected <!doctype but is 18420d7f1430a348837b97a31a80e374e3b00254 from maven-default-http-blocker for http://0.0.0.0/com/alibaba/nacos/nacos-client-mse-extension/1.4.2-SNAPSHOT/maven-metadata.xml
Downloaded from maven-default-http-blocker: http://0.0.0.0/com/alibaba/nacos/nacos-client-mse-extension/1.4.2-SNAPSHOT/maven-metadata.xml (63 kB at 19 kB/s)

从关键字maven-default-http-blocker可以找到相关资料。

简而言之,如果使用HTTP协议下载依赖,可能会导致中间人攻击。比如,本来想下载一个nacos-client的,结果下载的结果中被插入了恶意代码,然后开发人员运行了一下,黑客就能获得开发人员的计算机控制权了。

所以Maven 3.8.1就禁止了所有HTTP协议的Maven仓库。

详情见Maven 3.8.1的发布日志

问题是在日常开发中,我们经常会用到公司内部的maven仓库。这些仓库一般都是http协议,Maven 3.8.1禁止了http协议,那么就会导致开头的报错。

于是查了下,可以按照如下方式关闭:

修改全局的settings.xml文件(一般在系统路径下,比如mac就在/usr/local/Cellar/maven/3.8.1/libexec/conf/pom.xml/usr/local/Cellar/maven/3.8.2/libexec/conf/settings.xml),删除如下部分即可:

<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>

然后就可以继续正常使用Maven了。

P.S. 对于外部仓库,还是建议使用HTTPS协议访问,防止出现针对性的中间人攻击。

相关文章
|
缓存 Java Spring
解决IDEA报错:无法检索应用程序 JMX 服务 URL[Failed to retrieve application JMX service URL]亲测可用
解决IDEA报错:无法检索应用程序 JMX 服务 URL[Failed to retrieve application JMX service URL]亲测可用
2269 1
|
7月前
|
Java 应用服务中间件
解决tomcat启动报错:无法在web.xml或使用此应用程序部署的jar文件中解析绝对的url [http:java.sun.com/jsp/jstl/core]
解决tomcat启动报错:无法在web.xml或使用此应用程序部署的jar文件中解析绝对的url [http:java.sun.com/jsp/jstl/core]
1483 1
|
7月前
|
应用服务中间件 Android开发
Eclipse中启动tomcat后,无法访问localhost:8080(HTTP Status 404)
Eclipse中启动tomcat后,无法访问localhost:8080(HTTP Status 404)
183 0
|
JavaScript
Error: Unsupported URL Type: npm:fork-ts-checker-webpack-plugin@^5.0.11
如果你去搜索,答案都是去升级你的npm 在StackOverflow说是vue3得在非vue-cli环境得单独配置。地址: 还有说npm install --save-dev fork-ts-checker-webpack-plugin 众说纷纭,都解决不了
121 0
Springboot Http文件的访问 Url 转换 MultipartFile ,File 转 MultipartFile
Springboot Http文件的访问 Url 转换 MultipartFile ,File 转 MultipartFile
1010 0
|
XML JSON JavaScript
UE4 HTTP Request Plugin Description (DTHttpRequest)
UE4 HTTP Request Plugin Description (DTHttpRequest)
102 0
|
安全 Java Maven
from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories报错解决方案
最近升级Maven到3.8.1后,mvn编译的时候总是提示拉不到依赖,报错: Could not validate integrity of download from http://0.0.0.0/… 关键字maven-default-http-blocker。
1191 0
|
Java
SpringBoot报错:端口被占用Address already in use(Failed to start component [Connector[HTTP/1.1-8080)
SpringBoot报错:端口被占用Address already in use(Failed to start component [Connector[HTTP/1.1-8080)
417 0
SpringBoot报错:端口被占用Address already in use(Failed to start component [Connector[HTTP/1.1-8080)
|
Java 数据库
SpringBoot 项目启动出错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedde
SpringBoot 项目启动出错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedde
498 0
|
前端开发 Java Maven
SpringBoot 系列 web 篇之自定义返回 Http Code 的 n 种姿势
虽然 http 的提供了一整套完整、定义明确的状态码,但实际的业务支持中,后端并不总会遵守这套规则,更多的是在返回结果中,加一个 code 字段来自定义业务状态,即便是后端 5xx 了,返回给前端的 http code 依然是 200 那么如果我想遵守 http 的规范,不同的 case 返回不同的 http code 在 Spring 中可以做呢?
1046 0
SpringBoot 系列 web 篇之自定义返回 Http Code 的 n 种姿势