用注解的方式实现Mybatis插入数据时返回自增的主键Id

@Mapper

public interface UserMapper {

@Insert("insert into tbl_user (name, age) values (#{name}, #{age})")

@Options(useGeneratedKeys=true, keyProperty="userId", keyColumn="id")

     void insertUser(User user);

}

猜你喜欢

转载自blog.csdn.net/AinUser/article/details/82141840