org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 3报错解决

时间:2019-09-06 13:58:45   收藏:0   阅读:1419

报错的原因翻译出来:


预期的一个结果(或null)返回selectOne(),但发现:3


意思就是你想得到一个结果值,但是返回了三个结果值.

 

一般可能测试的时候我们存了几条一样的数据,在登录时,会把同用户名数据都返回.但是mapper接口的返回值是一个Bean.所以报错.


解决方法:


可以修改返回值为list,然后获取第一条

或者把数据库中重复的数据删掉.

原文:https://www.cnblogs.com/liruilong/p/11474157.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!