1. 程式人生 > >spring boot mybatis沒有掃描jar中的Mapper接口

spring boot mybatis沒有掃描jar中的Mapper接口

sta com ble str base 子目錄 run scan tis

只需要在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包中的。

spring boot mybatis沒有掃描jar中的Mapper接口