Unsatisfied dependency expressed through method 'traceFilterRegistration' parameter 0;
完整错误
Unsatisfied dependency expressed through method 'traceFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.servlet.Filter' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
先说下背景,这个错误时在eurekaserver中排除了spring-boot-start-actuator的依赖产生
修复方式
@Bean
Filter webRequestLoggingFilter() {
return new Filter() {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
filterChain.doFilter(servletRequest, servletResponse);
}
@Override
public void destroy() {
}
};
}