// 这个是正确的
@MapperScan("com.terry.demo.mapper")
public class PuaiApplication {
public static void main(String[] args) {
SpringApplication.run(PuaiApplication.class, args);
}
}
// 这个是罪魁祸首
@MapperScan("com.terry.demo")
public class PuaiApplication {
public static void main(String[] args) {
SpringApplication.run(PuaiApplication.class, args);
}
}
因为我mapper的文件在 com.terry.demo.mapper 下面:


本文探讨了在Spring Boot项目中正确使用@MapperScan注解的重要性。错误地将路径指定为'com.terry.demo'而非'com.terry.demo.mapper'导致了Mapper无法被扫描到的问题。通过调整注解路径至正确的子包位置,成功解决了这一问题。
459

被折叠的 条评论
为什么被折叠?



