Mybatis报错: A query was run and no Result Maps were found for the Mapped Statement
mybatis中的所有查询标签,都必须返回
resultType
或者resultMap
的值,否则就会报如上错误的,其实仔细看看因为报错原因的意思就好了
TestMapper.xml
演示:
<select id="getReturnNum" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM test_table
select>
Java 调用演示:
@Autowired
private TestMapper testMapper;
Integer mycount = testMapper.getReturnNum();
TestMapper.xml
演示:
<select id="getReturnAmount" resultType="java.math.BigDecimal">
SELECT IFNULL(SUM(mymoney), 0.00)
FROM test_table
select>
Java 调用演示:
@Autowired
private TestMapper testMapper;
Integer mycount = testMapper.getReturnAmount();
TestMapper.xml
演示:
<select id="getReturnList" resultType="com.test.entity.MyEntity">
SELECT *
FROM test_table
select>
Java 调用演示:
import com.test.entity.MyEntity;
@Autowired
private TestMapper testMapper;
List<MyEntity> myList = testMapper.getReturnList();
Mybatis报错: A query was run and no Result Maps were found for the Mapped Statement