问题
spring-boot 2.2 搭配 spring-cloud-alibaba 2.1.0 时启动报错
***************************
APPLICATION FAILED TO START
***************************
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:/C:/Users/Administrator/.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.1.RELEASE/spring-boot-actuator-2.2.1.RELEASE.jar!/org/springframework/boot/actuate/health/CompositeHealthIndicator.class
It was loaded from the following location:
file:/C:/Users/Administrator/.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.1.RELEASE/spring-boot-actuator-2.2.1.RELEASE.jar
为什么版本不能搞成一致
在项目中使用Reactive 访问Elasticsearch时用到了 ReactiveElasticsearchRepository,但这个类是Spring-data-elasticsearch3.2才有的,需要搭配spring-boot2.2使用,并且微服务组件使用alibaba nacos目前只有2.1版本,因此会出现这样的问题
解决办法
spring-cloud-alibaba 目前只有2.1,但查询nacos依赖
主要依赖context和commons,因此尝试将这两个依赖包排除,然后添加2.2版本的包
然后重启应用,发现已经可以正常工作,至此问题解决