【发布时间】:2015-08-30 14:31:33
【问题描述】:
我正在使用 Java 8 和 Spring 1.2.3 构建在 Tomcat 7 容器中运行的应用程序。
我确实使用非常简单的HandlerInterceptor 拦截了对我的网络应用程序的每一次调用,它记录了创建响应所花费的总时间以及每个请求的返回码。
我通过简单地添加 spring-boot-starter-actuator 依赖项来激活执行器端点,并通过调用添加拦截器
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
@Autowired
private Application application;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(application.executeTimeInterceptor());
}
}
显然,Spring Boot Actuator 管理的所有端点(/info、/health 等)都不会被拦截:如何确保拦截器拦截对我的应用程序的所有调用,包括调用执行器提供的端点的那些?
【问题讨论】:
-
你用的是tomcat还是jetty?
-
Tomcat 7 - 也添加到问题中
标签: java spring spring-mvc spring-boot