Internet .
UseGeneratedKeys is set to true and
keyProperty is set to the primary key field of the entity class, as follows:
<insert id="add" parameterType="Entity" useGeneratedKeys="true" keyProperty="EntityId"> insert into entity(...) values(...) </insert>
I tried many times to no avail, and finally read the following document:
http://www.cnblogs.com/fsjohnhuang/p/4078659.html
I saw the most important chrysanthemum:
Note: The return value of the mapper interface is still the number of records successfully inserted, but the difference is that the primary key value has been assigned to the id of the domain model entity.
I hope that people who encounter the same problem can see my blog and take less detours.
Well, you can continue to write code happily o(^▽^)o