背景,一次在使用Mybatis时,出现了org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'distinct' in 'class tk.mybatis.mapper.entity.Example$Criteria'
1、代码如下
@GetMapping("select")
public void select(Long id) {
Example example = new Example(Account.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", id);
List<Account> accountList = accountMapper.selectByExample(criteria);
log.info("accountList:{}", accountList);
}
2、修改如下
@GetMapping("select")
public void select(Long id) {
Example example = new Example(Account.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", id);
List<Account> accountList = accountMapper.selectByExample(example);
log.info("accountList:{}", accountList);
}
希望对你有所帮助