Similar to an error in MyBatis
There is no getter for property named ' Username ' in ' class java.lang.String '
There are 2 solutions without removing the IF label
Workaround 1
In the. xml file, replace the username with _parameter, which applies to a single parameter, as follows
<select id= "Selectuserbyname" parametertype= "String" resultmap= "user" >
select
<include refid= " Querycolumns "/> from
z_user,z_basic
<where>
<if test=" Username! = null ">
username Like CONCAT ('% ', #{username}, '% ')
</if>
</where>
</select>
<select id= "Selectuserbyname" parametertype= "String" resultmap= "user" >
select
<include refid= " Querycolumns "/> from
z_user,z_basic
<where>
<if test=" _parameter! = null ">
username Like CONCAT ('% ', #{username}, '% ')
</if>
</where>
</select>
<select id= " Selectalluser "resultmap=" user ">
select
<include refid=" Querycolumns "/>
, Text,password,z _basic.id from
z_user,z_basic
where
z_user.id=z_basic.z_basic.id
</select>
Workaround 2
DECLARE @param ("username") in the Mapper interface, as follows
List<user> Selectuserbyname (@Param ("username") String username);
I hope the above two methods are useful to everyone