@Mapper与@MapperScan的区别@Mapper1、角色2、位置: @MapperScan1、角色: 2、位置:两者的区别:
@Mapper 1,作用
接口在编译后生成相应的接口实现类
2,位置:在对应的某个接口类上生成对应的安装类
@ mapperpublicinterfaceitripusermapper { publicitripusergetitripuserbyid (param (value=' id ' ) Long id ) throws exception puse } @MapperScan 1,角色:扫描指定包中的所有接口类,并在编译后为所有接口生成适当的实现类
2、位置:说明扫描" cn.cvs.mapper "包下的所有mapper接口,生成对应的实现类
@mapperscan(cn.CVS.mapper ) ) springbootapplicationpublicclassspringbootapplication { publicstaticvoidmain } string }两者(适合接口少的时候)
2,@MapperScan是对整个包下所有接口类的注释,是批量操作。 使用@MapperScan后,接口类不再需要使用@Mapper注释
3,@MapperScan可以扫描多个软件包,参数只需要传递一个字符串数组。