因SpringBootApplication指定scanBasePackages后,出现问题
在使用mybatis 二级缓存的时候,当扩大了scanBasePackages范围后,出现了如下问题:
@SpringBootApplication(scanBasePackages = "com.zhenhunfan.itoken"})
@EnableEurekaClient
@MapperScan(basePackages = {"com.zhenhunfan.itoken.service.posts.mapper","com.zhenhunfan.itoken.common.mapper"})
public class ServicePostsApplication {
public static void main(String[] args) {
SpringApplication.run(ServicePostsApplication.class,args);
}
}
解决方法:精确定位scanBasePackages范围
@SpringBootApplication(scanBasePackages = {"com.zhenhunfan.itoken.common.context","com.zhenhunfan.itoken.service.posts"})
@EnableEurekaClient
@MapperScan(basePackages = {"com.zhenhunfan.itoken.service.posts.mapper","com.zhenhunfan.itoken.common.mapper"})
public class ServicePostsApplication {
public static void main(String[] args) {
SpringApplication.run(ServicePostsApplication.class,args);
}
}