错误信息
org.mybatis.spring.MyBatisSystemException: nested exception is
org.apache.ibatis.reflection.ReflectionException: There is no getter
for property named ‘userId’ in ‘class java.lang.Integer’
使用select代码块中如果只传入了一个参数,并且这个参数用在了if标签中,则必须使用@Param注解
Mapper接口更改为
/**
* 查询帖子数量
* @param userId 可以传入楼主的id
* @return 返回查询的数量
*/
int selectDiscussPostCount(@Param("userId")int userId);

本文介绍了解决MyBatis在使用Java Integer类型时遇到的反射异常问题,即找不到名为'userId'的属性获取器。文章提供了修正后的Mapper接口示例,说明如何通过使用@Param注解来正确传递参数。

1049

被折叠的 条评论
为什么被折叠?



