interface
public interface UserMapper {
int addUser(@Param("user") User user); #
}
XML file
<insert id="addUser" parameterType="com.rong.blog.entity.User">
insert into user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="username != null">
username,
</if>
<if test="password != null">
password,
</if>
<if test="address != null">
address,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="username != null">
#{username},
</if>
<if test="password != null">
#{password},
</if>
<if test="address != null">
#{address}
</if>
</trim>
</insert>
Error Reporting as described above:
org.apache.ibatis.binding.BindingException: Parameter ‘username’ not found
.
the reason
In front of the connector into the entity class parameter method adds @Param(“user”)
, to remove this annotation.