问题分析
该错误表明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.xml或build.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
8992

被折叠的 条评论
为什么被折叠?



