数据库
首页 > 数据库> > Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource

Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource

作者:互联网

问题原因

        在写spring配置文件的时候发现这个问题,根据报错信息发现是在写mybatis的映射文件的时候namespace写错了。

	org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'com/bjpowernode/dao/StudentDao.xml'. Cause: org.apache.ibatis.builder.BuilderException: Wrong namespace. Expected 'com.bjpowernode.dao.StudentDao' but found 'com.bjpowernode.dao'.

问题解决

        主要信息在最后一句,错误的命名空间,本该映射到接口,然而写成了包。

 Wrong namespace. Expected 'com.bjpowernode.dao.StudentDao' but found'com.bjpowernode.dao'.

        所以在写配置文件时一定要细心。

标签:sqlSessionFactory,resource,creating,com,dao,Error,org,bjpowernode
来源: https://blog.csdn.net/qq_45815784/article/details/118638918