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