我的服务器是 WAS的 在服务器上的日志文件中,查看到这样输出。
输出:
[16-1-15 9:53:35:449 CST] 00000070 SystemOut O 2016-01-15 09:53:35,449 [INFO ]: 保存
[16-1-15 9:53:35:449 CST] 00000070 ClassPathXmlA I org.springframework.context.support.AbstractApplicationContext prepareRefresh Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@9e12f51a: startup date [Fri Jan 15 09:53:35 CST 2016]; root of context hierarchy
[16-1-15 9:53:35:449 CST] 00000070 XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions Loading XML bean definitions from class path resource [config/applicationContext-common.xml]
[16-1-15 9:53:35:450 CST] 00000070 SystemOut O 2016-01-15 09:53:35,450 [INFO ]: 保存设备状态的异常!IOException parsing XML document from class path resource [config/applicationContext-common.xml]; nested exception is java.io.FileNotFoundException: class path resource [config/applicationContext-common.xml] cannot be opened because it does not exist
代码段:
//优化方式1
//bean工厂获取 映射文件 (新建一个新session) ClassPathXmlApplicationContext[只能读取在web-info/classes目录文件配置文件]
BeanFactory factory = new ClassPathXmlApplicationContext("classpath:config/applicationContext-common.xml");
//获取到 session工厂
//factory.getBean("sqlSessionFactoryBean");
BaseDao_Impl<Map<String, String>> dao = new BaseDao_Impl<Map<String, String>>();
//设置DAO层的sessionFacotry
dao.setSqlSessionFactory((SqlSessionFactory) factory.getBean("sqlSessionFactoryBean"));
BaseBiz_Impl<Map<String, String>> bbi = new BaseBiz_Impl<Map<String, String>>();
bbi.setDao(dao);