Error querying database. Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'user.insertUser!selectKey'. It's likely that neither a Result Type nor a Result Map was specified.
这是使用MyBatis最常见的一种错误,从其描述来看是user.insertUser!selectKey这个Statement没有Result Type
或Result Map
<insert id="insertUser" parameterType="com.luchao.mybatis.first.po.User"> <selectKey keyProperty="id" order="AFTER" > select LAST_INSERT_ID() </selectKey> insert into user(username,birthday,sex,address) value (#{username},#{birthday},#{sex},#{address}); </insert>
这里是没有 resultType 所致的。
mybatis中不管什么查询,都必须返回resultType或者resultMap的值,否则就会报错的。