mybatis异常

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): me.tspace.pm.dao.UserDao.getUser
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:178)
    at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:38)
    at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:49)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:42)
    at $Proxy22.getUser(Unknown Source)

........................

........................

Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for me.tspace.pm.dao.UserDao.getUser

    at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:775)
    at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:615)
    at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:608)
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:176)

    ... 34 more

两种情况:

1.

<mapper namespace="me.tspace.pm.dao.UserDao"> 

mapper的namespace写的不对!!!注意系修改。


2.

UserDao的方法在UserDao.xml中没有,然后执行UserDao的方法会报此错。


---------------------------------------------------------------------------------------------------------------------------------------------------------------

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' defined in class path resource [springMVC.xml]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [springMVC.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatisConfig.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for me.tspace.pm.dao.UserDao.getUser


mybatis的貌似mapper不允许重载.......


--------------------------------------------------------------------------------------------------------------------------------------------------------------------

### Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,plugins?,environments?,databaseIdProvider?,mappers?)".
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:79)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:63)
at man.send.TestPushEmail.testMybatis(TestPushEmail.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

节点顺序需要按照提示放置!

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

org.apache.ibatis.binding.BindingException: Type interface main.send.dao.SearchRecordDao is not known to the MapperRegistry.
at org.apache.ibatis.binding.MapperRegistry.getMapper(MapperRegistry.java:42)
at org.apache.ibatis.session.Configuration.getMapper(Configuration.java:639)
at org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper(DefaultSqlSession.java:218)
at main.send.service.impl.SearchRecordServiceImpl.getRandomId(SearchRecordServiceImpl.java:17)
at man.send.TestPushEmail.SearchRecordService(TestPushEmail.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39


  1. <mapper namespace="Mapper.UserMapper"> 
  2. <!-- 这里namespace必须是UserMapper接口的路径,不然要运行的时候要报错 “is not known to the MapperRegistry”--> 

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值