package com.roma.romaapi.config; import com.roma.romaapi.interceptor.JWTInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * 拦截器的配置文件 */ @Configuration public class InterceptorConfig implements WebMvcConfigurer { @Autowired private JWTInterceptor jwtInterceptor; @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(jwtInterceptor) //拦截的路径 .addPathPatterns("/**") //排除登录接口 .excludePathPatterns("/login/verifyCode","/api/login"); } }