首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

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

2012-10-21 
直接加载spring配置文件方式,可用于单元测试??// ApplicationContext context new?? ?ClassPathXmlApplic

直接加载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();
?}
}

热点排行