A query was run and no Result Maps were found for...原来是mapper.xml文件出了问题,是使用MyBatis最常见的一种错误
Posted 一念
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了A query was run and no Result Maps were found for...原来是mapper.xml文件出了问题,是使用MyBatis最常见的一种错误相关的知识,希望对你有一定的参考价值。
今天遇到一个问题,原来是mapper.xml文件出了问题,是使用MyBatis最常见的一种错误
报错的结果是这样的:
A query was run and no Result Maps were found for the Mapped Statement \'cn.zrgk.dao.RoleMapper.getRoleList\'.
It\'s likely that neither a Result Type nor a Result Map was specified.
org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement \'cn.zrgk.dao.RoleMapper.getRoleList\'.
It\'s likely that neither a Result Type nor a Result Map was specified. org.apache.ibatis.executor.resultset.FastResultSetHandler.validateResultMapsCount(FastResultSetHandler.java:177) org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:150) org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57) org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70) org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57) org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606)
我的mapper.xml文件中有个查询语句是这样写的:
大家看看图一,好像根本没有错误,对吗?再看看
是的,没错,我没有指定这个方法的返回类型,系统无法识别,于是就这样改了一下,发现不报错了
所以平时啊,我们要多多注意这些细节,更要去多加理解
以上是关于A query was run and no Result Maps were found for...原来是mapper.xml文件出了问题,是使用MyBatis最常见的一种错误的主要内容,如果未能解决你的问题,请参考以下文章
A query was run and no Result Maps were found for the Mapped Statement
出错:Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were foun
MyBatis报错:A query was run and no Result Maps were found for the Mapped Statement
MyBatis报错:A query was run and no Result Maps were found for the Mapped Statement
MyBatis报错:A query was run and no Result Maps were found for the Mapped Statement
ExecutorException: A query was run and no Result Maps were found for the Mapped Statement ‘com.win.m