광고
광고
반응형
@Configuration public class MvcConfig implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new UserInfoInterceptor()) .addPathPatterns("/**")//해당경로 접근전에 인터셉터가 가로첸다 .excludePathPatterns("/css/**", "/fonts/**", "/img/**", "/js/**","/scss/**","/vendor/**", "/login/**","/new/**", "/loginAction"); } }
interceptor 에서 로그기록을 DB에 남기려하다 Interceptor 안에서 의존성 주입 오류가 발생했다.
해당코드를
@Configuration public class MvcConfig implements WebMvcConfigurer { @Autowired private UserInfoInterceptor userInfoInterceptor; @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(userInfoInterceptor) .addPathPatterns("/**")//해당경로 접근전에 인터셉터가 가로첸다 .excludePathPatterns("/css/**", "/fonts/**", "/img/**", "/js/**","/scss/**","/vendor/**", "/login/**","/new/**", "/loginAction"); } }
이거로 바꿔준다.
new()를 통해 Interceptor 객체를 만들어서 등록하면 Spring Container에서 이 Interceptor를 관리하지 못한다고 한다.
당황하지말고 바꿔주자
반응형
'Spring' 카테고리의 다른 글
[Spring boot] JasperReport 사용법 - 3 (pdf 출력) 한글 오류 (0) | 2022.04.25 |
---|---|
[Spring boot] JasperReport 사용법 - 2 (pdf 출력) Java (0) | 2022.04.25 |
[MQTT] Mosquitto 설치 및 사용방법 - 2(pwfile 설정) (0) | 2021.12.14 |
[MQTT] Mosquitto 설치 및 사용방법 - 1 (0) | 2021.12.14 |
[Spring Boot] Error page 페이징 처리 (0) | 2021.07.30 |