• 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>
  • 相关阅读:
    Ubuntu 20.04 国内下载eclipse 网速慢解决方案
    Ubuntu20.04+GeForce RTX 2080 SUPER+cuda11.1+cudnn8.0.4+openCV4.4.0编译
    计算机专业考研复试面试----计算机组成原理
    计算机专业考研复试面试----操作系统
    Gabor滤波(个人学习)
    局部保留投影算法(个人学习)
    【转载】matlab常用函数
    latex常见的错误(自己经常出现的)
    latex常用的宏包(转载)
    C语言基础知识
  • 原文地址:https://www.cnblogs.com/tanglie/p/7874572.html
Copyright © 2020-2023  润新知