MyBatis-Plus报错Parameter ‘xxx‘ not found. Available parameters are [user, param1]解决办法

使用MyBatis-Plus写一个更新数据的方法报错
userMapper.java

@Mapper
public interface UserMapper extends BaseMapper<User> {
	int updateUserByUserId(@Param("user") User user);
}

userMapper.xml

<update id="updateUserByUserId" parameterType="com.demo.entity.User">
        update user
        <set>
            <if test="nickname != null and nickname != '' ">
                nickname = #{nickname},
            </if>
            <if test="email != null and email != '' ">
                email = #{email},
            </if>
        </set>
        where id = #{id}
    </update>

报错

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'nickname' not found. Available parameters are [user, param1]

删除@Param(“user”)即可:

int updateUserByUserId(User user);
上一篇:文件上传那些事:多图上传、大文件上传、断点续传功能实现与分析


下一篇:SpringBoot+Vue+ElementUI实现客服聊天