解决MyBatis报错:There is no getter for property named'Xxx'in'class xxx.xxx.Xxx'
问题
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>再次运行之后的结果就是正确的了

总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
SpringBoot 集成Resteasy实现RESTFul接口的详细过程
这篇文章主要介绍了SpringBoot集成Resteasy实现RESTFul接口,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2023-08-08
SpringBoot无法解析parameter参数问题的解决方法
使用最新版的 Springboot 3.2.1(我使用3.2.0)搭建开发环境进行开发,调用接口时出现奇怪的错,本文小编给大家介绍了SpringBoot无法解析parameter参数问题的原因及解决方法,需要的朋友可以参考下2024-04-04
springMvc异步的DeferredResult long polling应用示例解析
这篇文章主要为大家介绍了springMvc中DeferredResult的long polling应用示例解析,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-03-03


最新评论