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

相关推荐
谷哥的小弟27 分钟前
Spring Framework源码解析——AnnotationAwareOrderComparator
java·后端·spring·源码
谷哥的小弟30 分钟前
Spring Framework源码解析——StringUtils
java·后端·spring·源码
PieroPC39 分钟前
用 nicegui 3.0 + sqlite3 做个简单博客
前端·后端
天草二十六_简村人41 分钟前
jenkins打包制作Python镜像,并推送至docker仓库,部署到k8s
后端·python·docker·容器·kubernetes·jenkins
辜月十1 小时前
Docker-Compose 【Mysql】
后端
悟空码字1 小时前
SpringBoot实现系统监控:给应用装上“健康手环”
java·后端·监控
GuluGuluWater1 小时前
受够了同事的垃圾代码?我用 Go 写了个自动审查工具
后端
楼田莉子1 小时前
Linux学习:基础IO相关学习
linux·开发语言·c++·后端·学习
golang学习记1 小时前
Go 中获取两个切片交集的 6 种方法
后端
Cache技术分享1 小时前
261. Java 集合 - Java 开发必备:ArrayList 与 LinkedList 的选择攻略
前端·后端