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

Spring Boot2.5.5集成Spring Cloud2020.0.4启动创建compositeCompatibilityVerifier出错

问题根因说明

你遇到的CompatibilityNotMetException是Spring Cloud 2020.x版本新增的版本兼容校验机制触发的,该机制会自动校验当前项目中Spring Boot与Spring Cloud各组件的版本匹配度,哪怕显式指定了父工程版本,只要传递依赖带入了版本不一致的Spring相关组件,就会触发该异常。

问题定位步骤
  • 首先执行Maven依赖树命令,过滤Spring相关依赖,排查com.another.project:commons包是否传递引入了其他版本的Spring Boot或Spring Cloud组件,哪怕commons包的父工程Spring Boot版本和当前项目一致,只要其内部单独指定了子依赖版本,也会引发冲突
mvn dependency:tree -Dincludes=org.springframework.boot*,org.springframework.cloud*
  • 如果依赖树未排查出明显冲突,开启兼容校验的调试日志,启动项目后会打印具体不匹配的组件信息,在application.properties或者application.yml中添加如下配置:
logging.level.org.springframework.cloud.configuration=DEBUG

启动后搜索日志中Validation failed相关内容,会明确列出期望版本和实际引入的冲突版本。

解决方案
  1. 若确认是commons包传递引入了冲突依赖,在引入commons时排除冲突的Spring组件即可
<dependency>
    <groupId>com.another.project</groupId>
    <artifactId>commons</artifactId>
    <version>1</version>
    <scope>compile</scope>
    <exclusions>
        <!-- 把前面排查到的所有冲突依赖逐个添加在这里排除 -->
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>*</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  1. 若确认版本实际兼容只是校验逻辑误判,可直接关闭兼容校验,在配置文件中添加:
spring.cloud.compatibility-verifier.enabled=false
  1. 也可以直接升级Spring Cloud版本到2020.0.x系列的最终维护版本2020.0.6,该版本对Spring Boot 2.5.x的兼容性适配更完善,可避免很多隐性版本冲突问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.01 05:15:03