前提:springboot项目可以访问mysql,需要有UserMapper
一、编写代码
@Repository
public interface UserMapper extends BaseMapper<User> {
}
@Autowired
private UserMapper userMapper;
//Mybatisplus实现修改操作
@Test
public void updateUser(){
User user = new User();
user.setId(2L);
user.setAge(120);
int row = userMapper.updateById(user);
System.out.println("row:"+row);
}
二、运行结果