自定义Iterceptor实现WebMvcConfigurer重写addInterceptors(InterceptorRegistry)
@Configurationpublic class MVCInterceptorConfiguration implements WebMvcConfigurer {
@Autowired
private TokenInterceptor tokenInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(tokenInterceptor).addPathPatterns("/**")
.excludePathPatterns(
"/api-docs/**",
"/user/login",
);
}
}
addInterceptor设置自定义拦截规则
excludePathPatterns中设置的接口路径直接放行不验证token