You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

配置JFrog OSS的settings.xml后Maven项目构建报错求助

解决Maven构建时maven-default-http-blocker拦截JFrog HTTP仓库的问题

错误原因

Maven 3.8.1及以上版本默认启用了maven-default-http-blocker镜像规则,会拦截所有HTTP协议的仓库请求。你的JFrog仓库使用的是HTTP地址,因此被拦截,导致无法拉取maven-resources-plugin等依赖。

解决方法

1. 优先切换为HTTPS仓库(推荐)

如果你的JFrog OSS已配置HTTPS证书,直接将/root/.m2/settings.xml中的仓库地址从http://13.127.219.37:8081/artifactory/xxx替换为https://开头的地址即可。

2. 配置HTTP仓库豁免规则

若无法使用HTTPS,修改settings.xml,添加允许HTTP仓库的配置:

<settings>
  <!-- 保留原有其他配置,如servers等 -->
  
  <mirrors>
    <!-- 移除或注释掉默认的http拦截镜像(如果存在) -->
    <!-- <mirror>
      <id>maven-default-http-blocker</id>
      <mirrorOf>external:http:*</mirrorOf>
      <url>http://0.0.0.0/</url>
      <blocked>true</blocked>
    </mirror> -->
  </mirrors>

  <profiles>
    <profile>
      <id>allow-jfrog-http</id>
      <activeByDefault>true</activeByDefault>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://13.127.219.37:8081/artifactory/libs-release</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>false</enabled></snapshots>
          <allowInsecureProtocol>true</allowInsecureProtocol>
        </repository>
        <repository>
          <id>snapshots</id>
          <url>http://13.127.219.37:8081/artifactory/libs-snapshot</url>
          <releases><enabled>false</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
          <allowInsecureProtocol>true</allowInsecureProtocol>
        </repository>
      </repositories>
      <!-- 插件仓库也要配置,因为maven-resources-plugin属于插件依赖 -->
      <pluginRepositories>
        <pluginRepository>
          <id>central-plugin</id>
          <url>http://13.127.219.37:8081/artifactory/libs-release</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>false</enabled></snapshots>
          <allowInsecureProtocol>true</allowInsecureProtocol>
        </pluginRepository>
        <pluginRepository>
          <id>snapshots-plugin</id>
          <url>http://13.127.219.37:8081/artifactory/libs-snapshot</url>
          <releases><enabled>false</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
          <allowInsecureProtocol>true</allowInsecureProtocol>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
</settings>

3. 临时应急方案

执行Maven构建时添加参数跳过HTTPS校验:

mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -U

-U参数用于强制更新快照依赖,确保拉取最新资源。

验证

修改配置后,执行mvn clean install,如果不再出现maven-default-http-blocker相关错误,说明配置生效。

内容的提问来源于stack exchange,提问作者patrick

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 18:53:13