더북(TheBook)

다음과 같이 간단한 클래스를 작성해 이를 테스트할 수 있습니다.

예제 3-129 InheritanceDemo 클래스([[bean-inheritance]] InheritanceDemo.java)

package com.apress.prospring5.ch3.xml;

import org.springframework.context.support.GenericXmlApplicationContext;

public class InheritanceDemo {

    public static void main(String... args) {
        GenericXmlApplicationContext ctx =
            new GenericXmlApplicationContext();
        ctx.load("classpath:spring/app-context-xml.xml");
        ctx.refresh();

        Singer parent = (Singer) ctx.getBean("parent");
        Singer child = (Singer) ctx.getBean("child");

        System.out.println("부모:\n" + parent);
        System.out.println("자식:\n" + child);
    }

}
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.