IDEA自带maven报错maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories解决

问题描述

使用IDEA版本IntelliJ IDEA 2021.3
在这里插入图片描述
maven版本:3.8.1
在这里插入图片描述
更新依赖的时候错误提示:

maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories

解决方案

方案一:完美解决,将所有将镜像仓库从http 变成https

比如我引入的http://maven.aliyun.com/nexus/content/groups/public将期修改为
https://maven.aliyun.com/nexus/content/groups/public
如果私有仓库也是http且短时间无法改成https,建议采用方案二

方案二:临时去掉https校验

我使用的idea默认的maven,路径如下:

cd /Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/conf

编辑settings.xml

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

注释掉此段内容即不提示。

方案三:版本降至3.8.1以下版本

项目推荐

微服务项目:https://gitee.com/matevip/matecloud

### Maven 构建中 Artifact 传输失败的原因分析 当遇到 `Maven` 构建过程中无法从指定仓库传输 artifact 的问题时,通常是因为配置文件中的镜像设置阻止了某些协议的访问。具体到此案例中提到的错误消息: - **Error Message**: `Artifact Transfer Failed: com.whhim:whhim-parent:pom:3.0.2-SNAPSHOT blocked by mirror maven-default-http-blocker` 这表明当前使用的 Nexus 或其他远程仓库可能被默认 HTTP 阻断器 (`maven-default-http-blocker`) 所拦截[^1]。 #### 解决方案一:检查并修改本地 `settings.xml` 文件 在 Maven 安装目录下的 `conf/settings.xml` 中,默认存在一个名为 `maven-default-http-blocker` 的镜像配置项。该配置会阻塞所有通过 HTTP 协议而非 HTTPS 访问的请求。如果目标仓库仅支持 HTTP,则需要禁用这个镜像或者调整其优先级。 以下是典型的 `settings.xml` 修改方法: ```xml <mirrors> <!-- 注释掉或删除以下部分 --> <!-- <mirror> <id>maven-default-http-blocker</id> <mirrorOf>external:http:</mirrorOf> <name>Pseudo repository to block accidental usage of plain http repositories</name> <url>http://0.0.0.0/</url> </mirror> --> <!-- 添加自定义镜像配置 --> <mirror> <id>nexus-repository-id</id> <mirrorOf>*</mirrorOf> <url>https://your-nexus-server/repository/maven-public/</url> <name>Nexus Repository Manager</name> </mirror> </mirrors> ``` 上述操作可以确保 Maven 使用 HTTPS 进行通信,并绕过默认的 HTTP 阻断器。 #### 解决方案二:验证远程仓库地址 确认所依赖的远程仓库 URL 是否有效以及是否支持 HTTPS。例如,在 POM 文件中声明如下内容来明确指向特定版本库: ```xml <repositories> <repository> <id>custom-repo</id> <url>https://nexus.example.com/content/repositories/releases</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>custom-plugin-repo</id> <url>https://nexus.example.com/content/repositories/plugins</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </pluginRepository> </pluginRepositories> ``` #### 解决方案三:启用调试模式排查问题 运行命令时加上 `-X` 参数以获取更详细的日志信息,从而定位确切原因: ```bash mvn clean install -X ``` 这些日志可以帮助识别具体的网络连接异常或其他潜在问题。 --- ### 总结 通过对 `settings.xml` 和项目级别的 POM 文件进行适当调整,能够有效地解决因默认 HTTP 阻断而导致的 artifact 下载失败情况。同时建议始终采用安全可靠的 HTTPS 方式与外部资源交互。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值