MyBatisPlus新增返回主键ID

//service层
Student stu = new Student();
stu.setName("测试");
studentMapper.insertStu(stu);
System.out.println(stu.getId());
//Mapper层
@Insert("insert into student(name) values(#{name})")
@Options(useGeneratedKeys = true,keyProperty = "id")
void insertStu(Student stu);

你可能感兴趣的:(java,jvm,数据库)