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.问题思路的更多相关文章

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

  2. ### 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 ...

  3. ### 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: ...

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

  5. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xm

    mybatis解析xml配置文件出现异常: org.apache.ibatis.exceptions.PersistenceException: Error building SqlSession. ...

  6. mybatis异常:nested exception is org.apache.ibatis.builder.BuilderException: Error resolving JdbcType

    异常详细 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.Builde ...

  7. 解决: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 ...

  8. mybatis <fireach> 拼接sql语句 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'in'. Cause:

    <select id="getUserIn" parameterType="QueryVo" resultMap="userMap"& ...

  9. 报错 ———— Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; 不允许有匹配 "[xX][mM][lL]" 的处理指令目标。

    报错 <?xml version="1.0" encoding="UTF-8"?>  必须是XML文件的第一个元素且前面不能空格. ### Erro ...

随机推荐

  1. nopCommerce 3.9 大波浪系列 之 global.asax

    一.nop的global.asax文件 nop3.9基于ASP.NET MVC 5框架开发,而ASP.NET MVC中global.asax文件包含全局应用程序事件的事件处理程序,它响应应用程序级别和 ...

  2. nyoj_68:三点顺序(计算几何)

    题目链接 根据 AB*AC的值进行判断即可(ps,结果为0时不构成三角形) #include<iostream> #include<cstdio> #include<cs ...

  3. maven项目打包发布时跳过测试

    mvn命令: mvn clean install -Dmaven.test.skip=true eclipse build... 命令: clean install -Dmaven.test.skip ...

  4. SetConsoleWindowInfo 函数--设置控制台窗口的大小和位置

    SetConsoleWindowInfo函数 来源:https://msdn.microsoft.com/en-us/library/windows/desktop/ms686125(v=vs.85) ...

  5. 关于使用JQuery追加Option标签时使用三元运算符添加选中属性的解决办法

    $(data.resultList).each(function () {                        var selectedFlag = ${sessionScope.userI ...

  6. linux kill杀死进程

    背景:这个命令总是记不住,在此稍作记录,方便查看! 1 杀死进程 1.1 查看进程 此时如果我想杀了火狐的进程就在终端输入: $ kill -s 9 1827 其中-s 9 制定了传递给进程的信号是9 ...

  7. margin属性的正负值确定

    margin属性用来使用设置外边距,大多数情况使用正值,但是一些稍复杂的定位就会使用到负值,所以对margin属性的正负值理解是有必要的,本文同时解释了margin-right和margin-bott ...

  8. [js高手之路] es6系列教程 - 对象功能扩展详解

    第一:字面量对象的方法,支持缩写形式 //es6之前,这么写 var User = { name : 'ghostwu', showName : function(){ return this.nam ...

  9. java变量、二进制、数据类型、原码、补码、反码

    1. 变量  1. 他 她 我 你 某人 佚名 旺财 X-man x = 1     您好! 它    (变量就是自然语言中的代词)  2. int age = 15;// 00000000 0000 ...

  10. pythonchallenge

    # _*_ coding:utf-8 _*_ translated = '' message = 'g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr ...