2011-11-01 4 views
1

스프링 구성 요소 검사에 대해 약간의 질문이 있습니다.구성 요소 검사 : 스프링으로 빈로드

"my.package.test"에있는 모든 bean과 "my.package"에있는 하나의 bean을로드하고 싶습니다. "my.package.test"가 아니라로드하지만 내 TestBean로드되지, 내가 일치 콩 오류가없는에서

<context:component-scan 
    base-package="my.package.test" use-default-filters="false" > 
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> 
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/> 
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Component"/> 
    <context:include-filter type="assignable" expression="my.package.TestBean" /> 
</context:component-scan> 

내 모든 콩 : 이 작업을 수행하려면,이 XML을 썼다. My TestBean의 주석이 @Component에 잘 표시되어 있습니다.

로드되지 않은 이유를 모르겠습니다.

도움 주셔서 감사합니다.

답변

2

예제에서 TestBean은 "my.package"패키지에 있지만 Spring은 "my.package.test"아래의 모든 것을 검사합니다. 이것이 익명 처리 문제 일지는 확실하지 않지만 콩이 발견되지 않을 수 있습니다.

+0

예 "my.package.test"아래에서 Spring이 모두 검사하지만 "my.package"에 여러 개의 Bean이 있고 TestBean 중 하나만 검사하려고합니다. 나는이 라인이 다음을 허용한다고 믿었습니다 : 하나의 bean을 명시 적으로 선언했기 때문에 Kiva

+0

단지 하나의 bean을로드하려면 bean 그것을 스캔하는 것보다 : ''. 구성 요소 검색은 패키지를 자동으로 검색하고 빈을 만드는 데 사용됩니다. –

+0

그래, 내가 할 수있는 건 알지만 특정 콩을 만들지 않으면이 태그 (context : include-filter type = "assignable")의 목적은 무엇인가? – Kiva

관련 문제