当SSM框架发生sqlSessionFactory异常时的诊断点分析
2016-12-27 16:32
330 查看
当使用SSM框架时,有时候会发生sqlSessionFactory异常。那么如何诊断问题发生在哪里?
启动时报错:
产生这种问题时,最直接的判断是Spring的配置文件是否存在错误,或者MyBatis的配置文件是否存在错误。
诊断思路:
1、检查Spring的配置文件,例如applicationContext.xml中关于数据源的配置代码是否正确;
2、检查数据源的描述文件(如果有)是否正确,例如jdbc.properties属性文件
3、检查MyBatis的配置文件,例如mybatis.xml文件
4、在第3个检查点中如果引用了其它的映射文件,检查*.xml文件中MyBatis的配置映射内容是否正确。
以上内容都有可能导致sqlSessionFactory异常产生。
当然前提是已经在web工程中正确配置了必须的jar包。
完毕。
启动时报错:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/config/applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: .... nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
产生这种问题时,最直接的判断是Spring的配置文件是否存在错误,或者MyBatis的配置文件是否存在错误。
诊断思路:
1、检查Spring的配置文件,例如applicationContext.xml中关于数据源的配置代码是否正确;
2、检查数据源的描述文件(如果有)是否正确,例如jdbc.properties属性文件
3、检查MyBatis的配置文件,例如mybatis.xml文件
<configuration> <mappers> 检查这里的代码是否编写的正确 </mappers> </configuration>
4、在第3个检查点中如果引用了其它的映射文件,检查*.xml文件中MyBatis的配置映射内容是否正确。
以上内容都有可能导致sqlSessionFactory异常产生。
当然前提是已经在web工程中正确配置了必须的jar包。
完毕。
相关文章推荐
- C# 外部组件发生异常原因分析 [分析]
- Oracle DBA手记之“V$SQL视图显示结果异常的诊断”
- Microsoft.SqlServer.Management.SqlMgmt.SimpleJobSchedule”上的属性访问器“ScheduleRecurrenceAndTimes”发生以下异常:
- Mybatis发生异常: Cause: java.sql.SQLException: ORA-00911: 无效字符
- ssm框架搭建三---mybatis打印sql
- com.ibatis.common.jdbc.exception.NestedSQLException 今天用ibatis做数据查询时发生了这个异常
- SSM(框架)-异常1:面向接口式编程异常
- 在SQL 2008中总是出现问题:执行Transact-SQL语句或批处理时发生异常。如何解决?
- 赠送 HttpClient 和HttpURLConnection 的轻型网络框架 ---》常见异常分析
- 【框架-MFC】启动异常- 读取位置 0xfeeefef2 时发生访问冲突
- hibernate 使用sessionfactory的getCurrentSession()方法发生异常
- 使用OpenSessionInViewFilter 发生异常: No bean named 'sessionFactory'
- 错误 执行Transact-SQL语句批处理时发生了异常。无法设置主体'sa'的凭据
- SSH三大框架经常发生的异常以及解决方案
- com.microsoft.sqlserver.jdbc.SQLServerException: 使用 DBComms.receive 方法期间发生异常。
- 调用的目标发生异常 SqlCacheDependency
- 错误 执行Transact-SQL语句批处理时发生了异常。无法设置主体'sa'的凭据
- 创建数据库失败((Microsoft.SqlServer.Smo)) 执行 Transact-SQL 语句或批处理时发生了异常。 (Microsoft.SqlServer.ConnectionInfo
- 【性能诊断】六、并发场景的性能分析(windbg案例,大量的内部异常造成CPU飙升)
- Hibernate 发生异常:java.sql.SQLException: ORA-00928: 缺失 SELECT 关键字