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

Spring Boot 1.5.9引入spring-oxm依赖失败,如何获取正确版本?

解决Spring Boot中无法拉取spring-oxm依赖的问题

遇到这种情况,核心原因确实和Spring Boot的依赖版本管理机制有关,咱们一步步来排查解决:

  • 优先使用Spring Boot父依赖的版本管理
    Spring Boot的spring-boot-starter-parent已经通过dependencyManagement统一维护了所有Spring生态依赖的版本,你手动指定的3.2.2.RELEASE是非常老旧的Spring版本(对应Spring 3.x),大概率和你当前使用的Spring Boot版本不兼容,导致Maven无法正常解析拉取。

    最简单的解决方式是去掉手动指定的version标签,让父依赖自动管理版本:

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
    </dependency>
    

    这样Maven会自动拉取和你当前Spring Boot版本匹配的spring-oxm,既能保证兼容性,也不会出现拉取失败的问题。

  • 如果必须指定特定版本(比如原有代码依赖老版本API)
    如果你因为历史代码限制,必须使用某个特定版本的spring-oxm,不要直接在dependency里指定version,而是在dependencyManagement中覆盖版本配置,这样Spring Boot的依赖管理会优先采用你指定的版本:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-oxm</artifactId>
                <version>3.2.2.RELEASE</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <!-- 然后在dependencies中引入,无需重复指定version -->
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
        </dependency>
    </dependencies>
    
  • 排查仓库与缓存问题
    如果上述方法还是不行,可能是本地Maven缓存损坏或者仓库配置问题:

    1. 检查你的pom.xml是否配置了Maven中央仓库(有些镜像可能没有同步老旧版本):
      <repositories>
          <repository>
              <id>central</id>
              <url>https://repo1.maven.org/maven2/</url>
              <releases>
                  <enabled>true</enabled>
              </releases>
          </repository>
      </repositories>
      
    2. 清理本地Maven缓存并强制更新依赖:
      mvn clean install -U
      
  • 额外提醒
    注意3.2.2.RELEASE版本的spring-oxm对应Spring 3.x,和绝大多数现代Spring Boot版本(2.x及以上)兼容性很差,建议尽量升级你的代码适配Spring Boot对应的Spring版本,避免后续出现更多依赖冲突或API兼容问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 07:06:11