There is no getter for property named 'id' in 'class java.lang.Integer'
<select id="findUserById" parameterType="int" resultType="User"> select * from user1 <where> <if test="id != null and id != ''"> and id=#{id} </if> </where> </select>
在测试时报错:There is no getter for property named 'id' in 'class java.lang.Integer'
问题分析:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取integer.id值,引起报错。
解决方法: public User findUserById(@Param("id")int id);说明参数值。