问题描述:
在运行查询方法时出现这个错误
org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘str’ in ‘class java.lang.String’
Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘str’ in ‘class java.lang.String’
分析:
在查询资料后,发现是因为动态sql语句中,if标签的type属性写的是对象的属性名。而我使用的是单参数String,所以导致没有找到这个属性的getter方法。
解决方式:
在dao接口中添加注解@Param(“定义名称”)
解决。