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

Spring Cloud与Spring Boot版本不兼容致LoadBalancerAutoConfiguration启动错误

问题分析与解决方案

问题根源

你遇到的NoClassDefFoundError: org/springframework/beans/factory/aot/BeanRegistrationAotProcessor错误,核心原因是Spring Boot与Spring Cloud版本不兼容:

  • 项目指定Spring Boot 3.1.0作为父依赖,但使用的Spring Cloud版本是2022.0.3(Kilburn)。
  • Spring Cloud 2022.0.x系列仅兼容Spring Boot 2.7.x,而BeanRegistrationAotProcessor是Spring Boot 3.x才引入的AOT相关类,低版本Spring Boot依赖无法找到该类,最终引发类加载失败。
  • 从错误日志可见,运行时实际加载的是Spring Boot 2.7.12的jar包,说明Spring Cloud依赖强制拉取了低版本Spring Boot,造成版本冲突。

解决方案

方案1:升级Spring Cloud至兼容Spring Boot 3.1.x的版本

Spring Boot 3.1.x对应的Spring Cloud版本为2023.0.x(代号Gateway),修改pom.xml中的版本配置:

<properties>
    <java.version>17</java.version>
    <spring-cloud.version>2023.0.1</spring-cloud.version> <!-- 最新稳定版 -->
</properties>

方案2:降级Spring Boot至兼容Spring Cloud 2022.0.3的版本

若无需升级Spring Cloud,可将Spring Boot父版本降级到2.7.x系列:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.12</version>
    <relativePath/>
</parent>

后续操作

修改版本后执行以下步骤确保依赖更新:

  • 运行mvn clean install清理并重新构建项目
  • 若问题仍存在,可清空本地Maven仓库中冲突的依赖包

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 12:30:30