今天在用Mybatis的时候没有在启动类中加上@MapperScan(basePackages = {“”}),导致Mapper一直注入不进来

​ Mybatis在继承通用Mapper之后利用SelectOne()来查找某一条纪录

1
2
3
4
5
6
7
8
9
10
11
12
13
@RegisterMapper
public interface SelectOneMapper<T> {

/**
* 根据实体中的属性进行查询,只能有一个返回值,有多个结果是抛出异常,查询条件使用等号
*
* @param record
* @return
*/
@SelectProvider(type = BaseSelectProvider.class, method = "dynamicSQL")
T selectOne(T record);

}

参数为一个实例,实例中的属性作为查找的条件