acac.refresh(); // bean 등록 UserService service = acac.getBean(UserServiceImpl.class); service.show(); acac.close(); } }"> acac.refresh(); // bean 등록 UserService service = acac.getBean(UserServiceImpl.class); service.show(); acac.close(); } }"> acac.refresh(); // bean 등록 UserService service = acac.getBean(UserServiceImpl.class); service.show(); acac.close(); } }">
package com.anno.ex05;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class ServiceMain {

	public static void main(String[] args) {
		
		// XML 파일 대신에 Java Class을 이용하여 Bean을 정의.
		AnnotationConfigApplicationContext acac = new AnnotationConfigApplicationContext();
		acac.scan("com.anno.ex05"); // scan으로 사용할 패키지명 지정. = <context:component-scan base-package="com.anno.ex05"/>
		acac.refresh(); // bean 등록
		
		UserService service = acac.getBean(UserServiceImpl.class);
		service.show();
		
		acac.close();
	}

}