spring 整合Mybatis 错误:A query was run and no Result Maps were found for the Mapped Statement 'com.xxhh...

  运行环境: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>

 

转载于:https://www.cnblogs.com/tanglie/p/7874572.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值