C/C++教程

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'.

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

这篇关于Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!