no Result Maps were found for the Mapped Statement ‘com.feng.mybatis.mapper.

本文介绍了在MyBatis中配置mapper.xml时出现的一个常见错误,即误将`parameterType`配置为查询语句的参数类型,而应配置为`resultType`来指定返回结果的对象类型。通过对比错误与正确配置的示例,解释了为何配置`resultType`是解决查询返回结果问题的关键。
摘要由CSDN通过智能技术生成

1、错误信息

no Result Maps were found for the Mapped Statement 'com.feng.mybatis.mapper.

2、对错mapper.xml文件对比

<mapper namespace="com.feng.mybatis.mapper.BookMapper">
	<!--错误的配置:parameterType-->
    <!--<select id="getBookById" parameterType="com.feng.mybatis.bean.Book">
        select * from book where id=#{id}
    </select>-->
    <!--正确的配置:resultType-->
    <select id="getBookById" resultType="com.feng.mybatis.bean.Book">
        select * from book where id=#{id}
    </select>
</mapper>

3、错误原因
本来因该配置resultType,结果配置成了parameterType

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值