zoukankan      html  css  js  c++  java
  • spring 整合Mybatis 错误:A query was run and no Result Maps were found for the Mapped Statement 'com.xxhh.mapper.XxhhTableBabyCustomMapper.selectAllBaby'. It's likely that neither a Result Type nor a Resul

      运行环境:jdk1.7.0_17+tomcat 7 + spring:3.2.0 +mybatis:3.2.7+ eclipse

      错误:A query was run and no Result Maps were found for the Mapped Statement......

      错误原因:在使用springmvc+mybatis时候自定义mapper查询数据是提示以下错误

      解决办法:最后查询出在我的自定义mapper中没有写查询的返回类型也就是"resultType"每个查询都会返回个结果集,我们需要让系统知道返回什么样的结果集,导致出现下面问题

      错误代码: 

    [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] - Resolving exception from handler [public java.util.Map<java.lang.String, java.lang.Object> com.xxhh.controller.BabyController.selectAllBaby()]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'com.xxhh.mapper.XxhhTableBabyCustomMapper.selectAllBaby'. It's likely that neither a Result Type nor a Result Map was specified.
    [org.springframework.web.servlet.DispatcherServlet] - Could not complete request
    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'com.xxhh.mapper.XxhhTableBabyCustomMapper.selectAllBaby'. It's likely that neither a Result Type nor a Result Map was specified.
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
    at com.sun.proxy.$Proxy15.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
    at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
    at com.sun.proxy.$Proxy20.selectAllBaby(Unknown Source)

      相关代码:

    自定义mapper

        <!--  查询所有的宝贝 -->
        <select id="selectAllBaby" resultType="com.xxhh.po.XxhhTableBaby">
            SELECT * FROM xxhh_table_baby
        </select>
  • 相关阅读:
    git 报错 :Updates were rejected because the tip of your current branch is behind 解决方法
    selenium获取元素的input输入框已经输入的值的三种方法
    chrome(谷歌)浏览器,使用登录,收藏功能
    mybatis学习11-动态SQL语句
    mybatis框架学习-连接池与事务管理
    mybatis学习8-CRUD注解方式
    mybatis学习7-传统dao层开发
    mybatis学习6-使用代理接口的方式开发mybatis的底层实现
    mybatis框架学习-配置文件
    复制,删除 选中单元格对应的行
  • 原文地址:https://www.cnblogs.com/tanglie/p/7874572.html
Copyright © 2011-2022 走看看