예제 6-6은 org.springframework.core.io.ResourceLoader 클래스와 printMenu 메서드와 같이 스프링 컨테이너에서 인스턴스를 생성해서 사용 준비를 해두는 @Autowired 애너테이션의 사용을 보여준다. 다음으로 XML 설정인 예제 6-7과 유닛 테스트인 예제 6-8을 살펴보자.
예제 6-7 mydocuments-resourceloader-injection-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.views" />
<!-- 빈 정의 생략 -->
</beans>