在使用mybatis時報Could not set parameters for mapping異常。
最初以為是自己動態sql寫的有問題,反復修改,查看語法標簽。
最后發現是注釋的問題。
在xml文檔中,哪怕是sql statement中也不能使用/* */的注釋方法。
如:
1 <select id="listByCondition" parameterType="user" resultType="user"> 2 select * 3 from sys_user 4 <where> 5 /*where id = #{id};*/ 6 <if test="username!=null and username!=''"> 7 and username like #{username} 8 </if> 9 <if test="email !=null and email!=''"> 10 and email like #{email} 11 </if> 12 </where> 13 </select>
刪掉/*where id = #{id};*/注釋后,異常消除。