报错信息:
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'email' in 'class java.lang.String'
错误代码:
<select id="selectUserByEmail" resultType="com.shl.entity.SysUser" parameterType="java.lang.String" useCache="true"> select * from user where 1=1 <if test="email != null and email != ''"> and email='${email}' </if> </select>
解决办法:MyBatis如果参数为String的话,不管接口方法的形参是什么,在Mapper.xml中引用时需要改变为_parameter才能识别
<select id="selectUserByEmail" resultType="com.shl.entity.SysUser" parameterType="java.lang.String" useCache="true"> select * from user where 1=1 <if test="_parameter != null and _parameter != ''"> and email='${_parameter}' </if> </select>