1.添加属性statementType="STATEMENT"
2.且sql中的变量用${params},而不是#{params},如果是字符串类型的数据要手动加上引号
<select id="findBy" resultMap="userResultMap" parameterType="HashMap" statementType="STATEMENT">
SELECT `id`,`name`,`email`,`mobile`
FROM `${tableName}`
<trim prefixOverrides="and" prefix="WHERE">
<if test="id != null">
and `id` = ${id}
</if>
<if test="name != null">
and `name` = '${name}'
</if>
<if test="email != null">
and `email` = '${email}'
</if>
<if test="mobile != null">
and `mobile` = '${mobile}'
</if>
</trim>
</select>