手动从Spring中获取指定对象

1.创建ApplicationContext对象:

  ApplicationContext context = new FileSystemXmlApplicationContext("D:/workspace/test/resources/applicationContext-resource.xml");

2.调用getBean方法(注意参数以xml配置中的bean的名字匹配):
     trDAO = (ITestResultDAO) context.getBean("trDAO");

posted @ 2015-01-13 17:11  六月瓜  阅读(218)  评论(0编辑  收藏  举报