Development/Java
[Java Tips] JDK 1.4 이하에서 Spring BeanFactory Test하기
우™
2008. 3. 19. 01:25
FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext(
new String[]{
"C:/...../context1.xml",
"C:/...../context2.xml", .....
}
);
new String[]{
"C:/...../context1.xml",
"C:/...../context2.xml", .....
}
);
라고 코딩한 뒤 appContext.getBean(String beanName) 으로 Bean을 가져와서 알맞은 클래스로 캐스팅하면 된다.
classpath가 알맞게 지정되어 있다면 classpath로도 가져올 수 있다.(ClassPathXmlApplicationContext)
context내의 파일들이 classpath위주로 셋팅이 되어 있으므로 될 수 있으면 classpath를 권장한다.