问题描述
我在针对许多不同的Spring Boot微服务使用Spring Boot Administrator时遇到问题,其中 Web 左侧菜单选项(具有 Mappings 和 HTTP Traces 子选项)仅显示某些微服务。
可以使用的微服务和不能使用的微服务之间唯一明显的POM区别是Spring Boot Starter父版本;那些显示 Web 选项的用户正在使用2.1.6.RELEASE
版本,而那些没有使用更高版本的用户例如2.3.1.RELEASE
(我猜这会影响例如spring boot的版本执行器库)。
我将Spring Boot Admin Server的2.3.0版本与Spring Boot Starter Parent 2.3.1一起使用。
解决方法
对于任何偶然发现此问题的人,答案是从Spring Boot 2.0.0起,以便公开Spring Boot执行器httptrace端点(这是驱动 Web 选项的原因)。 Spring Boot Administrator),您现在还需要在Spring上下文中添加一个实现HttpTraceRepository
的bean。
例如
@Configuration
public class HttpTraceActuatorConfiguration {
@Bean
public HttpTraceRepository httpTraceRepository() {
return new InMemoryHttpTraceRepository();
}
}