报错详情:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'userName' not found. Available parameters are [arg1, arg0, param1, param2]
Caused by: org.apache.ibatis.binding.BindingException: Parameter 'userName' not found. Available parameters are [arg1, arg0, param1, param2]
报错前Mapper语句及xml的sql:
int updateByUserId(String userId,String userName);
<update id="updateByUserId" parameterType="String">
UPDATE NOTICE_USER u LEFT JOIN NOTICE_CONTENT c ON u.notice_id = c.id
<set>
u.STATUS = '1',
u.READ_TIME = sysdate(),
u.update_time = sysdate(),
<if test="userName != null and userName != ''">u.update_by = #{userName},</if>
</set>
WHERE c.status ='1' AND u.status = '0' AND u.USER_ID = #{userId};
</update>
报错原因:传两个及两个以上的参数给mybatis的时候,在没有用注解的情况下,xml文件中找不到对应名称的参数。
解决办法:
int updateByUserId(@Param("userId") String userId, @Param("userName") String userName);