记一次SpringBoot Filter的过滤器被重复执行问题
记一次SpringBoot Filter的过滤器被重复执行问题
debug发现过滤器 执行两次,后来定位到WebFilter和Component注解导致多次扫描,而这次需要用到WebFilter,所以注掉了Component
@Order(0)
//@Component
@WebFilter(urlPatterns = {"/*"})
@ConditionalOnProperty(name = "color.trace.start", havingValue = "true")
public class ThreadFilter implements Filter {
public ThreadFilter() {
System.out.println("color.trace.start...");
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse
servletResponse, FilterChain filterChain) throws IOException, ServletException {
String requestId = StrUtils.genRequestId();
ThreadLocalUtils.init(requestId);
MDC.put(MDC_TRACE_ID,requestId);
filterChain.doFilter(servletRequest, servletResponse);
ThreadLocalUtils.close();
}
@Override
public void destroy() {
}
}
@EnableColorProxy
@ServletComponentScan("com.player3.color.filter")
@SpringBootApplication
public class EshopOrderApplication {
public static void main(String[] args) {
SpringApplication.run(EshopOrderApplication.class, args);
}
}
---------------------------------------------------------------------------
国之殇,未敢忘!
南京大屠杀!
731部队!
(有关书籍《恶魔的饱食》)以及核污染水排海等一系列全无人性的操作,购买他们的食品和为它们提供帮助只会更加变本加厉的害你,呼吁大家不要购买日本相关产品
昭昭前事,惕惕后人
吾辈当自强,方使国不受他人之侮!
---------------------------------------------------------------------------
作者:三号小玩家
出处:https://www.cnblogs.com/q1359720840/
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。 版权信息

浙公网安备 33010602011771号