private ArticleInfoDaoImpl articleInfoDao; public void testSave(){ ApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "applicationContext.xml" }); //src下spring配置文件 BeanFactory factory = (BeanFactory) context; articleInfoDao = (ArticleInfoDaoImpl) factory.getBean("articleInfoDao");// 获取bean List<Articleinfo> list =articleInfoDao.get(); }
转载于:https://www.cnblogs.com/springmvc3/archive/2010/08/24/2224413.html