用@MapperScan和@Mapper注解都可以使得接口被其他类调用
- 前者可以指定扫描到的Mapper类所在包的路径,不需要每个接口都添加注解,允许同时指定多个包路径
- 后者需要添加在所有需要扫描到的Mapper文件
@Mapper
public interface OperLogMapper {
List<Operlog> queryOperLogInfo(List<String> months);
}
@SpringBootApplication
@ComponentScan(basePackages = {"com.mybatis"})
@MapperScan("com.mybatis.*.mapper")
public class DemoApplication {
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(DemoApplication.class);
// 关闭banner
springApplication.setBannerMode(Banner.Mode.OFF);
springApplication.run(args);
}
}