mybatis初始化SqlSessionFactory失败的几个原因分析
mybatis初始化SqlSessionFactory失败
总结原因有几点
1.resources中的xml配置文件放错位置或者是放的太深加载不到
比如 RoleDao因为放的比较包中包中所以扫描不到
2.xml文件里面有错文
比如mapper namespace的相对路径有问题 导致初始化错误
SqlSessionFactory异常
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory' defined in class path resource [spring/applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘class path resource [mybatis]'; nested exception is java.io.FileNotFoundException: class path resource [mybatis] cannot be opened because it does not exist
sqlSessionFactory配置文件路径错误
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
浅谈springboot @Repository与@Mapper的区别
本文主要介绍了浅谈springboot @Repository与@Mapper的区别,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2022-03-03SpringBoot如何配置MySQL和Oracl双数据源(Mybatis)
这篇文章主要介绍了SpringBoot如何配置MySQL和Oracl双数据源(Mybatis)问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2024-03-03
最新评论