ClassPathXmlApplicationContext

ApplicationContext context = new ClassPathXmlApplicationContext("service.xml");

if (ac.containsBean("swmsBussinessCodeManager")) {  

     BussinessCodeManager codeManager =       (BussinessCodeManager)ac.getBean("swmsBussinessCodeManager");

}

如果是两个以上:
ApplicationContext ac = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml","dao.xml"});

或者用通配符:
ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:/*.xml");

猜你喜欢

转载自minyongcheng.iteye.com/blog/1127136