mybatis中Could not set parameters for mapping异常

在使用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};*/注释后,异常消除。

 
posted @ 2022-04-02 21:20  SharpL  阅读(755)  评论(0编辑  收藏  举报