当前位置: 代码网 > it编程>编程语言>Java > 解决MyBatis报错:There is no getter for property named'Xxx'in'class xxx.xxx.Xxx'

解决MyBatis报错:There is no getter for property named'Xxx'in'class xxx.xxx.Xxx'

2024年08月08日 Java 我要评论
问题org.apache.ibatis.exceptions.persistenceexception:### error querying database. cause: org.apache.i

问题

org.apache.ibatis.exceptions.persistenceexception: 
### error querying database.  cause: org.apache.ibatis.reflection.reflectionexception: there is no getter for property named 'proname' in 'class com.smbms.pojo.provider'
### cause: org.apache.ibatis.reflection.reflectionexception: there is no getter for property named 'proname' in 'class com.smbms.pojo.provider'

解决方法

这个错误提示你的实体类的某个属性没有get方法那么你的 

问题可能有以下三种

  • 1.在实体类中的该属性名字写错了
  • 2.在实体类中的该属性没有写get方法
  • 3.在xxxmapper.xml文件中的该属性名字写错了

下面是我的错误之处

大家可以看到注释的部分为我之前的写错名字的属性,注释下面那行为修改后的

       <select id="querybyidandproname" resulttype="com.smbms.pojo.provider">
            select *
            from smbms_provider
            <where>
                <if test="id != null and id != ''">
                    and id = #{id}
                </if>
<!--             <if test="proname != null and id != ''">-->
                 <if test="proname != null and id != ''">
                     and proname like concat('%',#{proname},'%')
                 </if>
            </where>
        </select>

再次运行之后的结果就是正确的了

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com