集合类型选错导致的错误

org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned

1、报错
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne()

2、原因
在写 Mapper 接口的时候使用对象作为返回值,而在Mapper.xml 文件中的 SQL 语句查询出来的记录有很多条,所有使用对象没有办法进行接收。

3、解决办法
将 Mapper 接口的返回值改为 List<对象> 进行数据接收。

posted @ 2021-08-01 09:03  蔚蓝的海洋  阅读(36)  评论(0编辑  收藏  举报