xml
<insert id="insertForId" useGeneratedKeys="true" keyProperty="id">
insert into
student(sname,sage,ssex)
VALUES
(s.name,s.sage,s.ssex)
</insert>
Mapper:
public void insert(@Param("s")Student s);
ServiceImp:
Student s=new Student("小明","18","男")
mapper.insert(s);
System.out.println(s.getId())