只需在接口上加上@Options 注解, 格式如下
@Insert("insert into service_desc (service) values (#{S.service})")
@Options(useGeneratedKeys = true, keyProperty = "S.sid", keyColumn = "sid")
int addServiceDesc(@Param("S") ServiceInfo serviceInfo);
这样就可以在数据插入数据库之后把自动增长的主键 sid 自动赋予实体中 sid 属性