Maven项目报错:Blocked mirror for repositories

ERROR\] Failed to execute goal on project test: Could not resolve dependencies for project xxx: Failed to collect dependencies at my.test:dependency:version -\> my.test.transitive:transitive:version: Failed to read artifact descriptor for my.test.transitive:transitive:jar:version: Could not transfer artifact my.test.transitive:transitive:pom:version from/to maven-default-http-blocker ([http://0.0.0.0/](https://link.juejin.cn?target=http%3A%2F%2F0.0.0.0%2F "http://0.0.0.0/")): **`Blocked mirror for repositories:`** \[blocked-repository-id ([blocked.repository.org](https://link.juejin.cn?target=http%3A%2F%2Fblocked.repository.org "http://blocked.repository.org"), default, releases+snapshots)

如何解决

开发工具: IntelliJ IDEA

File------------------Setting------------------Build, Execution, Deplayment------------------------------Build Tools------------------------------Maven

Maven home path的下拉选项从 Bundled (maven 3) (Version: 3.8.1) 改成本地的 C:/yanessa/maven/apache-maven-3.6.3

报错原因

Maven 从 3.8.1 版本开始不支持 HTTP 仓库。这是因为 Maven 官方认为 HTTP 协议不够安全,容易受到中间人攻击。因此,从 3.8.1 版本开始,Maven 强制要求使用 HTTPS 协议来访问仓库。

如果你正在使用 Maven 3.8.1 或更高版本,并且需要访问 HTTP 仓库,你可以通过以下几种方式来解决这个问题:

  • 升级仓库到 HTTPS:联系仓库管理员,将 HTTP 仓库升级到 HTTPS。这是最安全和推荐的解决方案。

  • 配置 Maven 使用 HTTP:在 Maven 的 settings.xml 文件中添加以下配置,允许 Maven 使用 HTTP 协议:

    xml

    xml 复制代码
    <settings>
      <proxies>
        <proxy>
          <id>my-http-proxy</id>
          <active>true</active>
          <protocol>http</protocol>
          <host>your-http-proxy-host</host>
          <port>your-http-proxy-port</port>
          <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
        </proxy>
      </proxies>
      <mirrors>
        <mirror>
          <id>my-mirror</id>
          <mirrorOf>*</mirrorOf>
          <url>http://your-http-repository-url</url>
        </mirror>
      </mirrors>
    </settings>

    请注意,这种方法不推荐,因为它会降低安全性。

  • 降级 Maven 版本:如果你无法升级仓库或配置 Maven 使用 HTTP,你可以考虑降级到 Maven 3.8.0 或更低版本。但是,这也会带来安全风险,因此不推荐。

总之,为了确保安全,建议尽快将仓库升级到 HTTPS,并配置 Maven 使用 HTTPS 协议。

具体来说,你可以在 Maven 的发布说明中找到相关信息。以下是 Maven 3.8.1 发布说明的链接:

maven.apache.org/docs/3.8.1/...

相关推荐
追逐时光者29 分钟前
一款基于 Ant Design 设计语言实现、漂亮的 .NET Avalonia UI 控件库
后端·.net
笃行3503 小时前
从零开始:SpringBoot + MyBatis + KingbaseES 实现CRUD操作(超详细入门指南)
后端
该用户已不存在3 小时前
这几款Rust工具,开发体验直线上升
前端·后端·rust
用户8356290780513 小时前
C# 从 PDF 提取图片教程
后端·c#
L2ncE3 小时前
高并发场景数据与一致性的简单思考
java·后端·架构
水涵幽树4 小时前
MySQL 时间筛选避坑指南:为什么格式化字符串比较会出错?
数据库·后端·sql·mysql·database
ERP老兵_冷溪虎山4 小时前
从ASCII到Unicode:"国际正则"|"表达式"跨国界实战指南(附四大语言支持对比+中医HIS类比映射表)
后端·面试
HyggeBest4 小时前
Golang 并发原语 Sync Cond
后端·架构·go
老张聊数据集成4 小时前
数据建模怎么做?一文讲清数据建模全流程
后端
颜如玉4 小时前
Kernel bypass技术遥望
后端·性能优化·操作系统