在写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'.
所以在写配置文件时一定要细心。