SpringCloud 与 SpringBoot 版本不匹配所引发的问题

问题

先介绍下最初这个项目所依赖的 SpringCloud、SpringBoot 版本,如下:

  • SpringCloud : Greenwich.SR1
  • spring-boot-starter-parent : 2.1.3.RELEASE

近期由于项目需要,将该项目中的 spring-boot-starter-parent 升级到了 2.3.5.RELEASE,此时启动项目的时候会抛出如下错误:

Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
    org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthIndicator.<init>(DiscoveryCompositeHealthIndicator.java:42)
The following method did not exist:
    org.springframework.boot.actuate.health.CompositeHealthIndicator.<init>(Lorg/springframework/boot/actuate/health/HealthAggregator;)V
The method's class, org.springframework.boot.actuate.health.CompositeHealthIndicator, is available from the following locations:
    jar:file:/Users/eric/.m2/repository/org/springframework/boot/spring-boot-actuator/2.3.5.RELEASE/spring-boot-actuator-2.3.5.RELEASE.jar!/org/springframework/boot/actuate/health/CompositeHealthIndicator.class
The class hierarchy was loaded from the following locations:
    org.springframework.boot.actuate.health.CompositeHealthIndicator: file:/Users/eric/.m2/repository/org/springframework/boot/spring-boot-actuator/2.3.5.RELEASE/spring-boot-actuator-2.3.5.RELEASE.jar

解析

从上边的报错信息来看,大概的意思是 SpringCloud 在进行健康检查的时候,无法在 spring-boot-actuator-2.3.5.RELEASE.jar 中找到 CompositeHealthIndicator。这个问题应该是 SpringCloud 的版本(Greenwich.SR1)与 SpringBoot 的版本(2.3.5.RELEASE)不匹配而导致的。

解决

既然是版本不匹配导致的,那问题就简单了,只要调整下 SpringCloud 或 SpringBoot 的版本调整到可匹配就好了。若不能降低 SpringBoot 的版本(由于其他 jar 包依赖该版本的 SpringBoot),那我们可以单独将 spring-boot-actuator 的版本降级,以此来匹配较低版本的 SpringCloud,如下图:
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cab5

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值