今天使用基于MapperFactoryBean来实现MyBatis与Spring的整合,使用Mapper接口编程,一直报一个错误,调试了很久

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘customerMapper’ defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type ‘java.lang.String’ to required type ‘java.lang.Class’ for property ‘mapperInterface’; nested exception is java.lang.IllegalArgumentException: Cannot find class [mapper.CustomerMapper]

调试了很久,才发现是Mapper接口的名称和对应的Mapper.xml映射文件的名称不一致

在使用Mapper接口编程的方式,需要遵循一些规范

  1. Mapper接口的名称和对应的Mapper.xml映射文件的名称必须一致
  2. Mapper.xml文件中的namespace与Mapper接口的类路径相同
  3. Mapper接口中的方法名和Mapper.xml中定义的每个执行语句的id相同
  4. Mapper接口中方法的输入参数类型要和Mapper.xml中定义的每个sql的parameterType的类型相同
  5. Mapper接口方法的输出参数类型要和Mapper.xml中定义的每个sql的resultType的类型相同

解决Error creating bean with name xxx defined in class path resource [applicationContext.xml]错误相关推荐

  1. Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource [applicationContext

    学习spring框架时遇到一个问题,找了很久. 记录一个错误, D:\Java\jdk-14.0.2\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1 ...

  2. Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm

    报错信息如下: <span style="font-size:24px;">17:18:32,245 ERROR ContextLoader:307 - Context ...

  3. 解决Error creating bean with name ‘redisConnectionFactory‘ defined in class path resource...问题

    文章目录 1. 复现问题 2. 分析问题 3. 解决问题 1. 复现问题 今天在启动spring boot项目时,出现如下错误: org.springframework.beans.factory.B ...

  4. 解决 Error creating bean with name ‘dataSource‘ defined in class path resource 问题

    报错如下: java.lang.IllegalStateException: Failed to load ApplicationContextat org.springframework.test. ...

  5. 【J】BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource

    在做SSM博客系统的时候遇到以下报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with ...

  6. 日志Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource [applicationConte

    logimp报错日志直接看报错的最后一句. 另外bug:namespace="这里面应该用-来分隔,不应该用/",所以这里不应该复制,键盘自己敲 Error creating be ...

  7. 记一次SpringBoot操作redis报错 Error creating bean with name ‘dataSource‘ defined in class path resource解决方法

    代码块 以下为Springboot操作Redis一些简单的测试代码 maven依赖 <dependency><groupId>org.springframework.boot& ...

  8. Error creating bean with name ‘dataSource‘ defined in class path resource解决

    报错信息 ERROR 3592 - [ restartedMain] o.s.boot.SpringApplication : Application run failed org.springfra ...

  9. 启动springboot报错Error creating bean with name 'dataSource' defined in class path resource

    2019独角兽企业重金招聘Python工程师标准>>> 启动springboot报错Error creating bean with name 'dataSource' define ...

最新文章

  1. 高级工程考试通过总结
  2. modelsim-altera
  3. 论文解读:深度监督网络(Deeply-Supervised Nets)
  4. Ubuntu16.04安装TORCS
  5. html 一个圆圈一个c,如何用c语言程序画一个圆?
  6. mysql 回退查询_MySQL数据库:第十章:分页查询
  7. 【OpenCV 例程200篇】51. 图像增强—直方图反向追踪
  8. java串口设备中断_利用DMA双缓冲或半完成中断实现串口不定长数据的接收
  9. 求和(1,2,3.....n使其和为m的所有情况)
  10. 51单片机外围模块——红外通信
  11. scipy.linalg中kron的用法
  12. e430c参数 thinkpad_联想ThinkPad E430c(33651E1)
  13. Genymotion启动失败解决方案
  14. 【历史上的今天】1 月 21 日:微软创始人诞生;微信 11 周年;传奇黑客出生
  15. [架构之路-147]-《软考-系统分析师》- 7-企业信息化战略与实施-4-企业资源规划ERP和实施、信息资源管理
  16. 【高强度U盘文件夹加密工具】
  17. 制作dns服务器,宽带提速方法 制作dns服务器提速宽带 -电脑资料
  18. Python中的 if 语句简单介绍,中英文完整理解
  19. 键盘键和键盘键控制值一览表(键盘按键对应代码表)
  20. 从入门到实战,Netty多线程篇案例集锦

热门文章

  1. 你们要的圣诞帽~ Python实现
  2. Spring项目中value注解,@Value不能够读取到配置文件的值,无法成功注入值的问题解决(超简单)
  3. Windows更改显示dir命令为ls命令
  4. android多渠道打包(动态改变地址打包,只需改下版本号)
  5. 孤独之旅控制台小游戏
  6. 顶级赛事夺冠,入选百强榜单,四大“神兽”亮相,熊猫上路营运
  7. UE4-常见的宏-UFUNCTION
  8. PYTHON爬取高德地图POI
  9. FlexCAN简单介绍
  10. JAVA继承extends小练习①