<insert id="insertUser" useGeneratedKeys="true" keyProperty="id" keyColumn="id" parameterType="com.foreigners.entity.User"> insert INTO t_user(openId, name, gender, phoneNumber) VALUES (#{openId},#{name},#{gender},#{phoneNumber}) ON DUPLICATE KEY UPDATE name = #{name}, gender = #{gender}, phoneNumber = #{phoneNumber} </insert>