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

Spring Boot 3.9.1中@EnableEurekaClient是否弃用?添加依赖仍找不到

Spring Boot 3.9.1中@EnableEurekaClient注解的问题

在适配Spring Boot 3.x的Spring Cloud版本(比如2022.0.x及以后)中,@EnableEurekaClient注解已经被完全移除,并非单纯弃用。

这是因为从Spring Cloud 2022.0.0(代号Kilburn)开始,Eureka客户端实现了自动配置逻辑:只要你在pom.xml中添加了正确的eureka-client依赖,应用会自动识别并注册到Eureka服务器(前提是配置了有效的Eureka服务地址等参数),无需再通过注解手动启用。

解决步骤:

  1. 移除主类上的@EnableEurekaClient注解:该注解已不存在于当前版本的依赖包中,所以IDE会提示无法找到。
  2. 确认依赖版本适配:确保spring-cloud-starter-netflix-eureka-client版本与Spring Boot 3.9.1匹配,Spring Boot 3.9.1对应Spring Cloud 2023.0.x(Leyton系列),推荐通过Spring Cloud BOM统一管理版本:
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>2023.0.3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
</dependencies>
  1. 配置Eureka参数:在application.yml或application.properties中添加必要的Eureka服务配置,示例:
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 05:35:58