예제 3-11을 살펴보자. 이 예제는 스프링 컨테이너가 애너테이션을 붙인 클래스들과 그 안에 있는 애너테이션들을 찾도록 하는 XML 설정 파일과 필요한 태그를 보여준다. 이 파일에서는 <context:component-scan />이라는 특별한 태그를 사용한다. 이 태그는 설정 파일에도 선언되어 있는 XML 네임스페이스에 속한다. 이 새로운 네임스페이스는 뒤에 나오는 장들에서 보게 될 더 많은 태그들을 추가한다. 일단 여기서 이 태그는 스프링 컨테이너가 지정된 패키지(예제에서는 com.apress.isf.spring.annotated)와 그 서브패키지에서 애너테이션을 붙인 클래스를 찾도록 지시한다.
예제 3-11 mydocuments-annotations-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="com.apress.isf.spring.annotated" />
<bean id="webType" class="com.apress.isf.java.model.Type">
<property name="name" value="WEB" />
<property name="desc" value="Web Link" />
<property name="extension" value=".url" />
</bean>
</beans>