只需要在spring boot啟動類上加上注解,並指定jar包中接口文件包路徑即可
如下:
@ComponentScan(basePackages = "com.xx") @MapperScan(basePackages = "com.xx.**.dao") @SpringBootApplication @EnableCaching @EnableDiscoveryClient public class EnterApplication { public static void main(String[] args) { SpringApplication.run(EnterApplication.class,args); } }
如此com.xx包下的任意級子目錄下的dao包下的所有接口都會被掃描到,包括jar包中的。