더북(TheBook)

Note 앞에서 살펴본 클래스는 com.apress.prospring5.ch2.decoupled 패키지에 있습니다. 실제로 애플리케이션 개발자가 동일한 코드를 중복해서 새로 만들기보다는 재사용하기를 선호하는 것처럼 3장에서도 2장에서 사용한 예제를 사용하겠습니다. 소스를 받아보면 알겠지만, 코드 재사용을 위해 3장의 일부 프로젝트는 2장의 프로젝트에 의존하도록 정의돼 있습니다.

 

XML 파일에서 빈 정의 선언에 <bean ../> 태그를 사용했으며, 다음 app-context-xml.xml 파일에서 내용을 확인할 수 있습니다.

예제 3-18 빈 정의를 선언한 구성 파일([[setter-injection]] app-context-xml.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:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="renderer"
        class="com.apress.prospring5.ch2.decoupled.StandardOutMessageRenderer"
        p:messageProvider-ref="provider"/>
    <bean id="provider"
        class="com.apress.prospring5.ch2.decoupled.HelloWorldMessageProvider"/>
</beans>
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.