在controller测试时,遇到了如标题所示的错误,再三检查了确定了实体类里有getter方法,拼写无错误,xml文件中配置也没有问题,Junit中测试也没有报错
最终排查发现是#{xxxx}和实体类属性名不保持一致导致,最开始的时候报错是因为实体类是enableStatus属性,而mapper层的xml文件中,我写的是#{enable_status}…在这里,是区分大小写的,需要保持一致.
<if test="shopCondition.enableStatus !=null">
<!-- .enable_status报错 -->
and s.enable_status = #{shopCondition.enable_status}
</if>
<if test="shopCondition.enableStatus !=null">
<!-- enableStatus正常 -->
and s.enable_status = #{shopCondition.enableStatus}
</if>