今天在使用SpringCloud时遇到了一个问题,感觉有不少小伙伴会遇到,所以记录下来
在pom.xml中加入如下依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>启动项目后报错Thefollowingmethoddidnotexist:org.springframework.boot.actuate.health.CompositeHealthIndicator
*************************** APPLICATIONFAILEDTOSTART *************************** Description: Anattemptwasmadetocallamethodthatdoesnotexist.Theattemptwasmadefromthefollowinglocation: org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthIndicator.<init>(DiscoveryCompositeHealthIndicator.java:42) Thefollowingmethoddidnotexist: org.springframework.boot.actuate.health.CompositeHealthIndicator.<init>(Lorg/springframework/boot/actuate/health/HealthAggregator;)V Themethodsclass,org.springframework.boot.actuate.health.CompositeHealthIndicator,isavailablefromthefollowinglocations: jar:file:/Volumes/Others/MVNrepository/org/springframework/boot/spring-boot-actuator/2.2.4.RELEASE/spring-boot-actuator-2.2.4.RELEASE.jar!/org/springframework/boot/actuate/health/CompositeHealthIndicator.class Itwasloadedfromthefollowinglocation: file:/Volumes/Others/MVNrepository/org/springframework/boot/spring-boot-actuator/2.2.4.RELEASE/spring-boot-actuator-2.2.4.RELEASE.jar Action: Correcttheclasspathofyourapplicationsothatitcontainsasingle,compatibleversionoforg.springframework.boot.actuate.health.CompositeHealthIndicator问题所在就是——版本冲突 我使用的SpringBoot版本是2.2.4,而SpringCloud版本是Greenwich,二者的兼容还是有一定问题的,所以在启动时会报错:在spring-boot-actuator-2.2.4.RELEASE.jar下找不到CompositeHealthIndicator.class
解决方法有如下两种,我都已经测试过,这两种方法都可以解决问题
降级SpringBoot
把SpringBoot从2.2.4.RELEASE降级成2.1.4.RELEASE 升级SpringCloud
把SpringCloud从Greenwich.SR1升级成Hoxton.SR1按如上所示即可成功解决问题,小伙伴们赶紧去试一下吧~
本文内容总结:版本说明,情景复现,问题分析,解决方法,
原文链接:https://www.cnblogs.com/taiyii/p/12326603.html