大目老师,通用mapper在接口中中加入了其他的方法报错
来源:3-17 编写用户微服务与内容微服务-3

寂兮寥兮
2019-12-30
public interface UserAuthenticationMapper extends Mapper<UserAuthentication> {
UserAuthentication selectByMobile(String mobile);
}
<mapper namespace="com.kuaibu.user.dao.UserAuthenticationMapper">
<select id="selectByMobile" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from user_authentication
where mobile = #{mobile}
</select>
</mapper>
错误如下:
Invalid bound statement (not found): com.kuaibu.user.dao.UserAuthenticationMapper.selectByMobile
1回答
-
您好,可遵循如下步骤定位:
首先确认你的UserAuthenticationMapper.xml代码没有问题。从您贴出来的代码来看,应该是没有问题的,不过可以再确认下;
如果第一步确认没有问题,说明UserAuthenticationMapper.xml根本没有被加载到!于是可以如下定位:
首先看下你的UserAuthenticationMapper.xml是不是和你的UserAuthenticationMapper.java处在相同的目录,如果不在,需要额外配置 mybatis.mapper-locations=classpath:/mybatis/mapper/*.xml ,手动将UserAuthenticationMapper.java加载进去。
如果你的UserAuthenticationMapper.xml是不是和你的UserAuthenticationMapper.java处在相同的目录,那么99%的可能,是你的UserAuthenticationMapper.xml没有被包含在项目中。确认问题的方式:构建项目,然后打开构建完成的jar包(用解压缩工具打开即可),看里面有没有UserAuthenticationMapper.xml文件,如果没有的话,说明命中这个坑了。想办法在构建的时候,将xml文件包含到jar包里。
032020-10-28
相似问题