记一次使用mybatis-plus开发中遇到的问题:ReflectionException: There is no getter for property named ‘et‘ in ‘class

使用mybatis-plus整合springboot时,因为需要连表操作但是mybatisplus不支持,所以自己写了xml来映射

    <update id="update" parameterType="cn.azh.entity.Product">
        update t_product
        <set>
            <if test="name!=null and name!=''">
                name=#{name},
            </if>
            <if test="price!=null">
                price=#{price},
            </if>
            <if test="stock!=null">
                stock=#{stock},
            </if>
            <if test="type!=null and type.id!=null">
                typeId=#{type.id},
            </if>
            <if test="description!=null and description!=''">
                description=#{description},
            </if>
            <if test="productIntroImgs!=null and productIntroImgs!=''">
                productIntroImgs=#{productIntroImgs},
            </if>
            <if test="productParaImgs!=null and productParaImgs!=''">
                productParaImgs=#{productParaImgs},
            </if>
        </set>
        where id=#{id}
    </update>

但是测试发现报错product实体中的et属性没有getter方法,哥们直接愣住了,因为我的product中根本没有属性,甚至连带et两个字母的属性都没有,在仔细检查sql语句和实体类后确定没有问题但还是报错后上网寻求结果,在看了几个帖子后发现好像是因为BaseMapper中本身就有方法名为update的方法,在xml中可能他是反射到了原有的方法中导致报错

不知道如何解决不如从根本上解决问题,那就把从controller到xml从头到尾修改方法名改为updateProduct,改完运行,成功,问题解决

看帖子时发现另一个大佬遇到了同样的问题,他是通过重写方法解决的 加了个注解 下面带上他的原帖
使用注解解决

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值