我使用Spring-Boot和Eureka server构建了简单的微服务应用程序。现在,我想添加容错功能,以防 Eureka 服务器中注册的任何服务出现故障。所以,我使用了netflix-hystrix gradle dependency。但这种依赖性导致我的应用程序崩溃。
运行应用程序时,我收到以下错误消息:
Execution failed for task ':compileJava'. Could not resolve all files for configuration ':compileClasspath'. Could not find org.springframework.cloud:spring-cloud-starter-netflix-hystrix:.
作为参考,我添加了build.gradle文件的片段。
plugins {
id 'org.springframework.boot' version '2.4.4'
}
ext {
set('springCloudVersion', "2020.0.2")
}
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Run Code Online (Sandbox Code Playgroud) 在发布这个问题之前,我浏览了许多链接,例如:无法使用 Spring Cloud连接到Hystrix Dashboard 的命令指标流和无法连接到 Spring Cloud + Hystrix + Turbine 中的命令指标流 - MIME 类型(“文本/纯文本”)那不是“文本/事件流”等等,但仍然对我不起作用。
我正在使用 Spring Boot V2.2.2.RELEASE。
2020-01-14 22:52:23.805 INFO 8436 --- [io-8080-exec-10] ashboardConfiguration$ProxyStreamServlet :
Proxy opening connection to: http://localhost:8000/hystrix.stream
2020-01-14 22:52:23.806 INFO 8436 --- [nio-8080-exec-2] ashboardConfiguration$ProxyStreamServlet :
Proxy opening connection to: http://localhost:8000/hystrix.stream
2020-01-14 22:52:24.442 WARN 8436 --- [io-8080-exec-10] ashboardConfiguration$ProxyStreamServlet : Failed opening connection to http://localhost:8000/hystrix.stream : 404 : HTTP/1.1 404
2020-01-14 22:52:24.442 WARN 8436 --- [nio-8080-exec-2] ashboardConfiguration$ProxyStreamServlet : Failed opening connection …Run Code Online (Sandbox Code Playgroud)