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};*/注釋后,異常消除。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM