使用mybatis-plus一次报错
- mybatis-plus有一个自带selectList方法,传参是queryWrapper,如下代码
LambdaQueryWrapper<Product> queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(Product::getIsDeleted,0) .eq(Product::getCategoryId,categoryId) .orderByDesc(Product::getCreateTime); List<Product> productList = productMapper.selectList(queryWrapper); 这种方法是在开发过程中写的,运行正常
- 在后续的开发中,这个简单的列表 查询不满足需求,因此扩展了以下方法
Page<Product> page = new Page<>(pageNo,pageSize); productMapper.selectList(page, name, categoryId); 后来发现下面的方法正常,上面的方法包错了:Parameter ‘name’ not found. Available parameters are [ew, param1]
Page<Product> page = new Page<>(pageNo,pageSize); productMapper.selectPageList(page, name, categoryId);
- :mybatis的mapper文件是唯一根据方法名区分的,我们是自己的mapper.xml件中定义了跟mybatis-plus相同的方法名会覆盖mybatis-plus的方法,所以会报错。