使用注解:@Options(useGeneratedKeys=true,keyColumn=“id”)
package mapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import entity.R;
@Mapper
public interface RMapper {
@Insert("INSERT INTO r (name) VALUES (#{name})")
@Options(useGeneratedKeys=true,keyColumn="id")
public Integer save(R r);
}