zoukankan      html  css  js  c++  java
  • mybatis报错Mapped Statements collection does not contain value for com.inter.IOper

    首页 > 精品文库 > mybatis报错Mapped Statements collection does not contain value for com.inter.IOper

    mybatis报错Mapped Statements collection does not contain value for com.inter.IOper

    2015-04-09 浏览(52)

     

    [摘要:正在顺序挪用IOperation接心中的getAllItems方式时,涌现了以下毛病: Exception in thread main org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.inter.IOperation.getAllItems at org.apache.ib]

    在程序调用IOperation接口中的getAllItems方法时,出现了以下错误:

    Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.inter.IOperation.getAllItems
    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 com.sun.proxy.$Proxy0.getAllItems(Unknown Source)
    at analysis.ReviewsMining.processProcessedReviews(ReviewsMining.java:88)
    at analysis.ReviewsMining.main(ReviewsMining.java:152)
    Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.inter.IOperation.getAllItems
    at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:768)
    at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:603)
    at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:596)
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:176)

    出现这种错误有几种原因:

    1、命名空间没写对,如果使用mapper,则<mapper namespace="com.inter.IOperation">(IOperation是个接口,里面含有方法getAllItems)

    2、getAllItems方法在item.xml中没有,然后执行getAllItems方法会报错

    3、getAllItems方法的返回值是List<Item>,而select元素没有正确配置ResultMap,或者只配置了ResultType

    4、在与数据库连接相关的配置文件Configuration.xml中,在<mappers>中漏了<mapper resource="com/items/Item.xml"/>(这也是我这次错误的原因)

  • 相关阅读:
    Android 显示或隐藏标题栏进度条TitleProgressBar
    Android 利用Sharp样式设置文本框EditText圆角形状
    Android 中带有进度条效果的按钮(Button)
    Android 手势滑动,多点触摸放大缩小图片
    Android (Notification)消息推送机制
    Android AutoCompleteTextView控件实现类似百度搜索提示,限制输入数字长度
    Android 横向列表GridView 实现横向滚动
    Android 利用 AsyncTask 异步读取网络图片
    Android 各种功能代码收集
    Android 之 AlarmManager(定时器) 的介绍和使用
  • 原文地址:https://www.cnblogs.com/Baronboy/p/6074579.html
Copyright © 2011-2022 走看看