15:36:34,549 WARN DefaultListableBeanFactory:1416 - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemsMapper' defined in file [F:\apache-tomcat-7.0.77\webapps\ssm0531\WEB-INF\classes\cn\com\dao\ItemsMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Wrong namespace. Expected 'cn.com.dao.ItemsMapper' but found 'cn.com.mapper.ItemsMapper'. 15:36:34,549 WARN XmlWebApplicationContext:487 - Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.com.dao.ItemsMapper cn.com.service.ItemServiceImpl.itemsMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [cn.com.dao.ItemsMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemsMapper' defined in file [F:\apache-tomcat-7.0.77\webapps\ssm0531\WEB-INF\classes\cn\com\dao\ItemsMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Wrong namespace. Expected 'cn.com.dao.ItemsMapper' but found 'cn.com.mapper.ItemsMapper'.
在第一次常识整合SSM的时候爆了一个异常,说namespace错误,有效信息如下:
Cause: org.apache.ibatis.builder.BuilderException: Wrong namespace. Expected 'cn.com.dao.ItemsMapper' but found 'cn.com.mapper.ItemsMapper'.
我就在application-dao.xml查看是不是包扫描器有问题,找了半个小时也没看到我那里有个Mapper配的叫做cn.com.mapper.ItemsMapper,然后我就疯了,但是我冷静下来想想,既然配置的是自动包扫描,如果是手动配置的话,肯定要把接口对应的****mapper.xml配到application-dao.xml中,但是我使用的是自动扫描,那么myBatis肯定是去解析我的application-dao.xml中的一些内容,肯定包括namespace等等。
我去找了具体的***mapper.xml文件,看里面的namespace,果不其然,写成了cn.com.mapper.ItemsMapper'。
回头想想原因,我这几个***mapper.xml映射文件,是用MyBatis提供的逆向工程工具,自动生成的,然后指定的包名,和后来复制目的地的包名不一致,导致框架自动解析器解析不到对应的内容,所以就会报错。
记录一下启动成功的截图
org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML.问题思路的更多相关文章
-
The error may exist in com/bjpowernode/dao/StudentDao.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderExcept
The error may exist in com/bjpowernode/dao/StudentDao.xml### Cause: org.apache.ibatis.builder.Builde ...
-
### Error building SqlSession. ### The error may exist in SQL Mapper Configuration ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibat
这是一个由粗心导致的错误,具体报错如下: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSessio ...
-
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.
在做多表映射查询时,在同一个resultMap中写了1:1映射和1:n映射,结果测试时报错如下: org.apache.ibatis.exceptions.PersistenceException: ...
-
Error building SqlSession. ### The error may exist in dao/UserMapper.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration(2 字节的 UTF-8 序列的字节 2 无效。)
关于在学习Mybatis框架时运行报错 Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error building ...
-
Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xm
mybatis解析xml配置文件出现异常: org.apache.ibatis.exceptions.PersistenceException: Error building SqlSession. ...
-
mybatis异常:nested exception is org.apache.ibatis.builder.BuilderException: Error resolving JdbcType
异常详细 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.Builde ...
-
解决:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'requestMap.maintenancename != null and requestMap.maintenance
异常如下:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.Builde ...
-
mybatis <;fireach>; 拼接sql语句 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression &#39;in&#39;. Cause:
<select id="getUserIn" parameterType="QueryVo" resultMap="userMap"& ...
-
SpringBoot和mybatis整合报错:Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 152; columnNumber: 10; 元素类型为 ";mapper";
很明显,报错是xml有问题,于是去检查,发现: 由于粗心,保存的时候,按的太频繁,多按了个s在里面,导致启动报错!
随机推荐
-
[Java面试一]面试复习大纲.
一.Java基础部分 (搞定所有技术之后才考虑复习的技术点) 1.数组中的排序问题(笔试或者机试,前者可能性更大) 2.面向对象的理解 3.集合相关的问题,比如hashmap跟hashtable的区别 ...
-
python的最最最最最基本语法(3)
模块:在Python中,一个.py文件就称之为一个模块(Module). 为了避免模块名冲突,Python又引入了按目录来组织模块的方法,称为包(Package).例如两个名不hello.py的模块分 ...
-
CS小分队第一阶段冲刺站立会议(5月6日)
冲刺阶段第一天 今日任务:完成游戏2048退出自动保存和进入自动读取功能,完善其他功能.
-
腾讯QQ企业邮箱POP3/SMTP设置
腾讯企业邮箱支持通过client进行邮件管理. POP3/SMTP协议 收发邮件server地址分别例如以下. 接收邮件server:pop.exmail.qq.com (port 110) 发送邮件 ...
-
recursive - simple screenshot but detail principle.
the code below demonstates the principle of the'recursive-call' that the programing beginner may be ...
-
CoreText实现图文混排之点击事件
今天呢,我们继续把CoreText图文混排的点击事件补充上,这样我们的图文混排也算是圆满了. 哦,上一篇的链接在这里 http://www.jianshu.com/p/6db3289fb05d Cor ...
-
jQuery的remove和detach的区别
1.remove([expr]) 概述:从DOM中删除所有匹配的元素. 这个方法不会把匹配的元素从jQuery对象中删除,因而可以在将来再使用这些匹配的元素.但除了这个元素本身得以保留之外,其他的 ...
-
自定义控件 进度条 ProgressBar-2
使用 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:bqt ...
-
排序算法Java实现(冒泡排序)
算法描述:对于给定的n个记录,从第一个记录开始依次对相邻的两个记录进行比较,当前面的记录大于后面的记录时,交换位置,进行一轮比较和交换后,n个记录中的最大记录将位于第n位:然后对前(n-1)个记录进行 ...
-
maven安装、配置
maven的安装和配置 1.将maven解压到自定义文件夹下.例如解压到如下目录(解压目录最好不要有中文字): 2:配置环境变量:一定要注意要用分号:与其他值隔开 3.在cmd中测试,验证是否安装成 ...