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

使用Maven无法解析依赖问题求助(Maven 3.8.9)

Maven依赖拉取失败问题排查

环境信息

  • Maven版本:3.8.9

pom.xml配置

<repositories>
    <repository>
        <id>central</id>
        <name>Maven Repository Switchboard</name>
        <url>https://repo.maven.apache.org/maven2</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>

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>

报错内容

Failed to collect dependencies at org.springframework.boot:spring-boot-starter-oauth2-client:jar:2.3.0.RC1
 -> org.springframework.security:spring-security-oauth2-client:jar:5.3.1.RELEASE 
-> com.nimbusds:oauth2-oidc-sdk:jar:7.1.1 -> com.nimbusds:nimbus-jose-jwt:jar:8.8
 -> net.minidev:json-smart:jar:[1.3.1,2.3]: No versions available for net.minidev:json-smart:jar:[1.3.1,2.3] within specified range -> [Help 1]

解决步骤

  1. 刷新依赖缓存:执行命令 mvn clean install -U,强制Maven重新拉取依赖,排除本地缓存损坏或未更新的问题。
  2. 显式锁定依赖版本:在pom.xml的<dependencies>节点中添加以下配置,覆盖传递依赖的版本范围,指定该范围内存在的具体版本(如2.2.2):
<dependency>
    <groupId>net.minidev</groupId>
    <artifactId>json-smart</artifactId>
    <version>2.2.2</version>
</dependency>
  1. 检查仓库可用性:确认https://repo.maven.apache.org/maven2可正常访问,若网络受限,可替换为国内镜像仓库(如阿里云Maven镜像),在settings.xml中配置对应镜像规则。
  2. 验证镜像配置:当前的maven-default-http-blocker仅拦截HTTP协议的外部仓库,你的配置仓库均为HTTPS协议,该镜像规则不会影响依赖拉取,无需调整。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 08:56:06