在Mapper.xml最下面填写
<!-- 批量插入生成的兑换码 --> <insert id ="insertCodeBatch" parameterType="java.util.List" > <selectKey resultType ="java.lang.Integer" keyProperty= "id" order= "AFTER"> SELECT LAST_INSERT_ID() </selectKey > insert into redeem_code (bach_id, code, type, facevalue,create_user,create_time) values <foreach collection ="list" item="reddemCode" index= "index" separator =","> ( #{reddemCode.batchId}, #{reddemCode.code}, #{reddemCode.type}, #{reddemCode.facevalue}, #{reddemCode.createUser}, #{reddemCode.createTime} ) </foreach > </insert >