Monday, February 26, 2007

Spring Basics

GET BEAN OUT OF SPRING CONFIG FILE

//define location of the config files referenced by the bean(s)
ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext(
new String[]{"classpath*:config1.xml",
"classpath*:/subdir/config2.xml",
"classpath*:etc.xml"});
//get the bean
MyBean myBean = (MyBean)springContext.getBean("myBeanName");

No comments: