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

启动Eureka注册中心时遇LoadBalancerAutoConfiguration异常求助

问题解决方案:Eureka注册中心启动时ClassNotFoundException异常

问题分析

这个异常的核心原因是Spring Cloud 2022.0.2(代号Kilburn)与你使用的Spring Boot 2.7.11版本不兼容。Spring Cloud Kilburn要求的Spring Boot版本是3.0.x及以上,而BeanRegistrationAotProcessor是Spring Boot 3.0才引入的AOT相关类,2.7.x版本不存在该类,因此触发找不到类的错误。

解决办法

以下两种方案任选其一即可:

方案1:升级Spring Boot到兼容版本

将Spring Boot版本升级至3.0.x或3.1.x(Spring Cloud 2022.0.2推荐的Spring Boot版本范围为3.0.0-3.0.9),修改pom.xml中的Spring Boot父依赖版本:

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

注意:Spring Boot 3.x要求Java版本至少为17,若当前使用Java 8或11,需同步升级JDK。

方案2:降级Spring Cloud到兼容Spring Boot 2.7.x的版本

Spring Boot 2.7.x对应的稳定Spring Cloud版本是2021.0.6(代号Jubilee),修改pom.xml中的Spring Cloud依赖管理版本:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>2021.0.6</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

此方案无需升级JDK,适合继续使用Java 8/11的场景。

额外说明

你之前尝试添加elasticsearch依赖与该问题无关,此异常本质是版本不兼容导致。修改版本后,仅保留spring-cloud-starter-netflix-eureka-server依赖即可正常启动Eureka注册中心。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 17:27:01