import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringHelper {
static ApplicationContext ctx = null;
static {
try {
String[] s = new String[] { "applicationContext-dao.xml",
"applicationContext-biz.xml" };
ctx = new ClassPathXmlApplicationContext(s);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Object getBean(String beanId) {
try {
return ctx.getBean(beanId);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringHelper {
static ApplicationContext ctx = null;
static {
try {
String[] s = new String[] { "applicationContext-dao.xml",
"applicationContext-biz.xml" };
ctx = new ClassPathXmlApplicationContext(s);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Object getBean(String beanId) {
try {
return ctx.getBean(beanId);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}