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

相关推荐
Victor35623 分钟前
MongoDB(28)什么是地理空间索引?
后端
Victor35625 分钟前
MongoDB(29)如何创建索引?
后端
皮皮林5511 小时前
面试官:什么是 fail-fast?什么是 fail-safe?
后端
陈随易2 小时前
前端大咖mizchi不满Rust、TypeScript却爱上MoonBit
前端·后端·程序员
雨中飘荡的记忆3 小时前
Multi-Agent + Skills + Spring AI 构建自主决策智能体
后端·spring
我叫黑大帅4 小时前
Go 语言并发编程的 “工具箱”
后端·面试·go
用户8356290780515 小时前
Python 实现 PowerPoint 形状动画设置
后端·python
用户908324602735 小时前
Spring Boot 缓存架构:一行配置切换 Caffeine 与 Redis,透明支持多租户隔离
后端
tyung5 小时前
zhenyi-base 开源 | Go 高性能基础库:TCP 77万 QPS,无锁队列 16ns/op
后端·go