더북(TheBook)

이 코드에서 볼 수 있듯이 이 예제에서 크게 바뀐 부분은 없습니다. 이전 예외와의 차이는 클래스 이름이 바뀐 것, 빈이 InitializingBean을 구현했다는 것, 구현 로직이 afterPropertiesSet() 메서드로 이동했다는 것 정도입니다. 다음 코드는 이 예제의 구성 파일입니다.

예제 4-5 구성에서 초기화 콜백 메서드 제거([[initializing-bean]] app-context-xml.xml)

<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"
        default-lazy-init="true">

    <bean id="singerOne"
          class="com.apress.prospring5.ch4.SingerWithInterface"
          p:name="John Mayer" p:age="39"/>

    <bean id="singerTwo"
          class="com.apress.prospring5.ch4.SingerWithInterface"
          p:age="72"/>

    <bean id="singerThree"
          class="com.apress.prospring5.ch4.SingerWithInterface"
          p:name="John Butler"/>
</beans>
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.