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>

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

猜你喜欢

转载自blog.csdn.net/lemonzjk/article/details/124553147