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);說明參數值。


免責聲明!

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



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