SpringBoot3 Jersey依赖导致“EurekaRegistration.getEurekaClient() is null“异常分析

问题分析

该错误表明Eureka客户端未正确初始化,EurekaRegistration.getEurekaClient()返回null。默认情况下,EurekaClient 使用 Spring RestTemplate进行 HTTP 通信(参见Spring Cloud Netflix),并且Jersey相关依赖版本由spring cloud dependencies管理,如果项目仍残留旧版本Jersey依赖,可能会导致兼容性问题。

解决方案

方案一显式配置HTTP客户端application.yml中强制使用Spring的RestTemplate(参见https://github.com/spring-cloud/spring-cloud-netflix/pull/4281):

eureka:
  client:
    jersey:
      enabled: false

方案二:检查并移除Jersey依赖版本号pom.xmlbuild.gradle中排查并移除以下Jersey相关依赖版本号,交由spring cloud dependencies管理:

<!-- 移除具体的版本号 -->
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-client</artifactId>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-core</artifactId>
</dependency>
<dependency>
    <groupId>com.sun.jersey.contribs</groupId>
    <artifactId>jersey-apache-client4</artifactId>
</dependency>

验证依赖树 执行以下命令检查冲突依赖:

mvn dependency:tree | grep jersey
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值