Mybatis报错: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'problem' not found.
原因就在于mapper,一定是传参出了问题。
百思不得其解时,突然发现,Param声明的参数名与数据库sql中的名字写的不一致了。[原来的声明@Param("question") String question ]
userMapper.xml:
<select id="checkAnswer" resultType="int" parameterType="map">
SELECT count(1)
from user
where del = 1
and username = #{username}
and problem = #{problem}
and answer = #{answer}
</select>
UserMapper.java:
int checkAnswer(@Param("username") String username, @Param("problem") String problem, @Param("answer") String answer);