ontext:component-scan   어노테이션 대부분 검색하는듯

 

대표적으로

@Controller @Service @AutoWWired 등이 있다.

 

서블릿컨테이너꺼

<context:component-scan base-package="com.plays.js"

scoped-proxy="targetClass" resource-pattern="**/*.class" use-default-filters="false" >

<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />

</context:component-scan>

 

스프링컨테이너꺼

<context:component-scan base-package="com.plays.js"

scoped-proxy="targetClass" resource-pattern="**/*.class"> 

<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />

</context:component-scan>

 

 

옵션을 보면

base-package 말그대로 베이스 패키지

scoped-proxy 프록시 방식

resource-pattern 스캔 패턴

use-default 기본적인것들을 검사할껀지 여부

include-filter  예외적으로 등록시킬 필터

exclude-filter 예외적으로 제외할 필터

 

위의 2가지로 형태를 나누게 된것은

Controller부분은 실제로 서블릿 컨테이너에서 관리하도록 저기서만 스캔했고

나머지 것들은 스프링컨테이너가 관장하니 그쪽으로 선언한것이다.

그러니깐 실제로

 

서블릿 컨테이너에서는 컨트롤러 빈을 만들고

스프링 컨테이너에서는 서비스 오토와이어 리소스 등등의 빈을 만든다.

 

빈이 과다하게 등록시키지않기뒤해서 이러한 구성을 시도했다.

 

아직 이유는 잘모르지만 이렇게 구분지어놓으라고 하더라

'오락기 > spring' 카테고리의 다른 글

ControllerClassNameHandlerMapping  (0) 2017.11.16
Transactional 과 advice  (0) 2017.08.07
HandlerMethodArgumentResolver  (0) 2017.07.11

+ Recent posts