我正在尝试使用Netflix eureka服务发现和hystrix断路器构建简单的Spring Cloud应用程序。
断路器服务:
@EnableCircuitBreaker
@SpringBootApplication
@EnableEurekaClient
public class PluralsightEurekaFastpassConsoleApplication {
public static void main(String[] args) {
SpringApplication.run(PluralsightEurekaFastpassConsoleApplication.class, args);
}
}
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>
spring-cloud-starter-netflix-hystrix
</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Hystrix仪表板
@EnableHystrixDashboard
@SpringBootApplication
@EnableDiscoveryClient
public class PluralsiteHystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(PluralsiteHystrixDashboardApplication.class, args);
}
}
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
控制台日志
2018-07-04 20:15:25.051信息17516 --- [nio-8088-exec-1] ashboardConfiguration $ ProxyStreamServlet:代理打开连接 至:http://localhost:8088/actuator/hystrix.stream 2018-07-04 20:15:25.052信息17516 --- [nio-8088-exec-6] ashboardConfiguration $ ProxyStreamServlet:代理打开连接 至:http://localhost:8088/actuator/hystrix.stream 2018-07-04 20:15:25.058 WARN 17516 --- [nio-8088-exec-1] ashboardConfiguration $ ProxyStreamServlet:打开连接失败 到http://localhost:8088/actuator/hystrix.stream:404:HTTP / 1.1 404 2018-07-04 20:15:25.058警告17516 --- [nio-8088-exec-6] ashboardConfiguration $ ProxyStreamServlet:打开连接失败 到http://localhost:8088/actuator/hystrix.stream:404:HTTP / 1.1 404
我尝试了Unable to connect to Command Metric Stream for Hystrix Dashboard with Spring Cloud
但问题仍然存在。
答案 0 :(得分:3)
问题没有提供足够的信息,所以最好的办法是确保:
actuator
上下文路径下部署并访问了断路器服务中的弹簧启动执行器端点。为了检查执行器实际在哪里,请分析启动日志,如果没有有关已部署端点的信息,请向微服务的应用程序启动中添加--debug
。 第二步似乎将揭示真正的问题。
然后可以使用management.context-path
设置执行器上下文路径,或者应自定义hystix仪表板