zl程序教程

您现在的位置是:首页 >  后端

当前栏目

spring boot mybatis没有扫描jar中的Mapper接口

SpringjarBootmybatis接口 没有 扫描 Mapper
2023-09-11 14:19:26 时间

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