添加过滤器:seata解绑
This commit is contained in:
@ -0,0 +1,36 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.config;
|
||||||
|
|
||||||
|
import io.seata.core.context.RootContext;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* seata拦截器配置类 解除seata绑定
|
||||||
|
*
|
||||||
|
* @author fqj
|
||||||
|
* @date 2022-01-13
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class SeataInterceptorConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
InterceptorRegistration interceptor = registry.addInterceptor(new HandlerInterceptor() {
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
if (!Objects.isNull(RootContext.getXID())) {
|
||||||
|
RootContext.unbind();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
interceptor.addPathPatterns("/**");
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user