springBoot mybatis包扫描问题怎么解决
springBootmybatis包扫描@MapperScan(basePackages={"com.zscat.*.dao","com.zscat.*.*.dao"})@EnableTransactionManagement(proxyTargetClass=true)@SpringBootApplication@MapperScan(basePackages={"com.zscat.*.dao","com.zscat.*.*.dao"})publicclassShopServiceApplicatio
springBoot mybatis 包扫描
@MapperScan(basePackages = {"com.zscat.*.dao","com.zscat.*.*.dao"})@EnableTransactionManagement(proxyTargetClass = true)
@SpringBootApplication
@MapperScan(basePackages = {"com.zscat.*.dao","com.zscat.*.*.dao"})
public class ShopServiceApplication {
public static void main(String[] args) {
SpringApplication application = new SpringApplication(ShopServiceApplication.class);
application.run(args);
}
}springBoot 扫描不到 mybatis 接口包
只需要在spring boot启动类上加上注解,并指定jar包中接口文件包路径即可
@MapperScan(basePackages = "com.xx.**.dao")
如果使用@Controller和@EnableAutoConfiguration 注解还应该再加上一个注解:@ComponentScan 就可以了。
@Controller和@EnableAutoConfiguration没有扫描注解的功能,而@ComponentScan是
springboot专门用来扫描@Component, @Service, @Repository, @Controller等注解的注解
总结:
使用springboot启动类配置扫描的两种注解配置方式:
1、@Controller
@EnableAutoConfiguration @ComponentScan
2、@SpringBootApplication
@SpringBootApplication注解等价于@Configuration, @EnableAutoConfiguration and @ComponentScan
另外application.java(启动类)也应该按照官方的建议放在root目录下,这样才能扫描到Service和dao,不然还会引起,扫描不到注解的问题。
--- 更新日期:2018-10-14 ---
最近用了最新的springboot 2.0.5.RELEASE 版本 多了一种新的扫描注解,新版的springboot application可以放在任意位置,只要加上
@ComponentScan(basePackages = {"com.oskyhang", "com.frames"})注解就可以,注解指定扫描的包,就可以扫描到,更灵活方便。
Windows 10 是一款微软推出的经典操作系统,拥有硬件兼容性与多任务处理能力。它更偏向把系统状态查看和常用调节动作放在一起,适合需要持续观察和微调设备状态的场景。
极度公式是一款跨平台专业LaTeX公式识别编辑软件,支持OCR公式识别和多平台编辑。和使用说明,避免使用,享受完整功能与稳定支持。做扫描整理、文字提取和表格转换时,它能把识别后的处理步骤接得更顺,资料录入这类场景会省下不少时间。
















