/*当传非实体类作为参数时,如果sql中没有使用 <if test='xxx !=null and xxx != "" '> where xxx = #{xxx}</if>时,可以直接传没有任何问题,
但当 使用了if表达式之后,该方法调用就会报 Mybatis错误: There is no getter for property named 'xxx'
*/
解决办法就是在形参中直接定义这个参数名,也就是使用@Param("xxx") ,例如:
@Select({"<script> select * from xxx <if test='dept !=null and dept != \"\" '> where dept = #{dept}</if></script>"})
List<ZZZ> getXXX(@Param("dept")String dept); //以上这么用就不会报错
@Select(" select * from xxx where dept = #{dept}")
List<ZZZ> getXXX(String dept); //以上这么用也不会报错
@Select({"<script> select * from xxx <if test='dept !=null and dept != \"\" '> where dept = #{dept}</if></script>"})
List<ZZZ> getXXX(String dept); //以上这么用就报错