读书人

直接加载spring配置文件形式可用于单

发布时间: 2012-10-21 09:00:07 作者: rapoo

直接加载spring配置文件方式,可用于单元测试


??// ApplicationContext context= new
?? ?ClassPathXmlApplicationContext(clapath

);//加载classpath下文件也就是Web-INF/classes下的文件
??
??String local = "WebRoot/WEB-INF/applicationContext-hibernate.xml";


??ApplicationContext context = new FileSystemXmlApplicationContext(local);
??//cacheService为applicationContext-hibernate.xml中的bean的id 可以对应Dao也可以对应service层bean的id
??ICacheService cs = (ICacheService) context.getBean("cacheService");
??cs.createBussinessCacheData();
?}
}

读书人网 >编程

热点推荐