Spring Cloud 引入 hystrix-dashboard 依赖,启动报错

梅玉堂
2023-12-01

报错信息:java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V

错误原因:引入的 hystrix-dashboard 依赖与 Spring Cloud 和 Spring Boot 版本不匹配,Spring Cloud 版本为 Hoxton.SR3,Spring Boot 版本为 2.2.6

解决办法:只引入以下依赖即可

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
    <version>2.2.2.RELEASE</version>
</dependency>

如果还不行的话,尝试先引入以下依赖

// 这两个依赖配合才引入了dashboard
<dependency>
    <groupId>com.netflix.hystrix</groupId>
    <artifactId>hystrix-javanica</artifactId>
    <version>RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-hystrix-dashboard</artifactId>
</dependency>

然后再将这两个依赖替换为以下依赖即可

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
    <version>2.2.2.RELEASE</version>
</dependency>
 类似资料: