项目里有实习生讨论为何他使用@mapper注解,但是mapper却找不到的问题。下面进行分析。
环境
项目是采用SpringBoot,Mybatis-SpringBoot-Starter等库。
使用区别
方法一:使用@Mapper 直接在每个对应的Mapper类上面添加注解@Mapper。Mapper类较多时,这样使用比较麻烦。
@Mapper
public interface IssueMapper {
/**
* 查询试题
*
* @param issueId 试题ID
* @return 试题
*/
public Issue selectIssueById(Long issueId);
}
大约 3 分钟