스프링이 빈으로 등록을 할 때 WebInitializer 에 의해서

AnnotationConfigWebApplicationContext appConfig = new AnnotationConfigWebApplicationContext();
appConfig.register(WebAppConfig.class);

WebAppConfig 가 읽히고 그 다음에 DispatcherServletConfig 로 읽힘

componentScan 시에는 bean 으로 등록 후 파일 순서대로 읽힌다.

componetScan 시에 component 로 등록된 애들을 bean으로 등록하는데 (Interceptor) component 등록 시 localeresolver 는 아직 bean으로 등록되지 않아서 오류 남.

package org.example.overview.interceptor;

import java.lang.annotation.*;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Interceptor {
    String value() default "";
}
@Configuration
@EnableTransactionManagement(proxyTargetClass = true)
@EnableWebMvc
@ComponentScan(basePackages = "org.example.overview",
        useDefaultFilters = false,
        includeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION, value = {Interceptor.class,Controller.class})}
)

그래서 componentScan 과 분리해서 생각하기 위해서 Interceptor 클래스를 추가로 넣어줌.

컴포넌트랑 인터셉터를 분리하기. 인터셉터를 컴포넌트로 두지 말고 디스패처서블릿 실행되기 전에만 인터셉터가 실행되면 되기에 각 인터셉터를 component 가 아닌 새로 생성한 interceptor 로 annotation 을 달아줌.