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

升级Spring Boot至2.6.4后Spring核心组件版本未更新至5.x求助

Spring Boot 2.6.4升级后Spring框架核心组件版本未同步至5.3.17的解决方法

已将Spring Boot版本升级至2.6.4,但spring-context、spring-aop、spring-beans、spring-expression等核心组件版本仍停留在4.3.12.RELEASE,未更新至目标的Spring框架5.3.17版本。以下是mvn dependency:tree的执行结果:

\- org.springframework.boot:spring-boot-starter-actuator:jar:2.6.4:compile
[INFO]    +- org.springframework.boot:spring-boot-starter:jar:2.6.4:compile
[INFO]    |  +- org.springframework.boot:spring-boot:jar:2.6.4:compile
[INFO]    |  |  \- org.springframework:spring-context:jar:4.3.12.RELEASE:compile
[INFO]    |  |     +- org.springframework:spring-aop:jar:4.3.12.RELEASE:compile
[INFO]    |  |     +- org.springframework:spring-beans:jar:4.3.12.RELEASE:compile
[INFO]    |  |     \- org.springframework:spring-expression:jar:4.3.12.RELEASE:compile
[INFO]    |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.6.4:compile
[INFO]    |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.6.4:compile
[INFO]    |  |  +- ch.qos.logback:logback-classic:jar:1.2.10:compile
[INFO]    |  |  |  +- ch.qos.logback:logback-core:jar:1.2.10:compile
[INFO]    |  |  |  \- org.slf4j:slf4j-api:jar:1.7.36:compile
[INFO]    |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.1:compile
[INFO]    |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.7:compile
[INFO]    |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.36:compile
[INFO]    |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO]    |  +- org.springframework:spring-core:jar:4.3.12.RELEASE:compile
[INFO]    |  \- org.yaml:snakeyaml:jar:1.29:compile
[INFO]    +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.6.4:compile
[INFO]    |  +- org.springframework.boot:spring-boot-actuator:jar:2.6.4:compile
[INFO]    |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.2.1:runtime
[INFO]    |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.4:runtime
[INFO]    |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.11.4:runtime
[INFO]    |  \- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.8.10:runtime
[INFO]    \- io.micrometer:micrometer-core:jar:1.8.3:compile
[INFO]       +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile
[INFO]       \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime

解决方案

  • 强制指定Spring框架版本
    在pom.xml的<properties>节点中直接声明目标Spring框架版本,Spring Boot的依赖管理会自动采用该版本替换旧组件:

    <properties>
        <spring-framework.version>5.3.17</spring-framework.version>
    </properties>
    
  • 精准排查并排除冲突依赖
    执行以下命令定位引入旧版本Spring组件的根源依赖:

    mvn dependency:tree -Dverbose -Dincludes=org.springframework
    

    找到冲突依赖后,在对应的<dependency>节点中排除旧版本的Spring组件:

    <dependency>
        <!-- 替换为实际冲突的依赖坐标 -->
        <groupId>xxx</groupId>
        <artifactId>xxx</artifactId>
        <version>xxx</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-expression</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    
  • 确认Spring Boot父依赖配置
    确保pom.xml中正确引入Spring Boot父依赖,它会自动管理Spring框架及相关组件的版本,避免手动版本冲突:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.4</version>
        <relativePath/> <!-- 从Maven仓库自动获取 -->
    </parent>
    

注意:Spring Boot 2.6.x版本默认绑定的Spring框架版本就是5.3.x系列,出现旧版本组件说明存在依赖冲突。优先通过父依赖或属性指定版本解决,排除冲突是兜底方案。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 02:35:23