Spring

Junit Test [A ServletContext is required to configure default servlet handling]

아이티.파머 2015. 11. 2. 15:00
반응형

java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling

단위 테스트 (Junit)중에 위와 같은 오류에 직면할수 있다.

 

테스트에서 사용하는 스프링 Root Context에 Controller가 포함된 경우에 발생될수 있다고 한다.

 

Compoment Scan 시 사용하는 Annotation에서 다음과 같이 Controller를  Compoment Scan에서 제외시킨다.

@ComponentScan(basePackages = "com.ctb.pilot", excludeFilters = {
        @Filter(Configuration.class), @Filter(Controller.class) })

 

잊어 버릴까봐 적어둔다.

 

 

반응형