早点的时间是直接在Mapper类上面添加注解@Mapper,这种方式要求每一个mapper类都需要添加此注解,比较麻烦。

现在通过使用@MapperScan可以指定要扫描的Mapper类的包的路径,比如:

@SpringBootApplication
@MapperScan("com.lz.water.monitor.mapper")
// 添加对mapper包扫描
public class Application {


public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}


}

同时,使用@MapperScan注解多个包



* @SpringBootApplication  
* @MapperScan({"com.kfit.demo","com.kfit.user"})  
* public class App {  
*     public static void main(String[] args) {  
*        SpringApplication.run(App.class, args);  
*     }  
* } 



如果如果mapper类没有在Spring Boot主程序可以扫描的包或者子包下面,可以使用如下方式进行配置



* @SpringBootApplication  
* @MapperScan({"com.kfit.*.mapper","org.kfit.*.mapper"})  
* public class App {  
*     public static void main(String[] args) {  
*        SpringApplication.run(App.class, args);  
*     }  
* } 
*

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信