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

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