多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## @InheritMapper 此为不常用的一个注解。当不仅仅满足BaseMapper提供的功能,项目提供了自己的BaseMapper的时候,比如CommonMapper,会遇到一个问题,就是自己CommonMapper的的公共sql查询方法,是查询CommonMapper指定的sql文件,还是继承接口的sql文件 BeetlSQL默认下是查询CommonMapper的指定文件,例子如下 ```java @SqlResource("common") public static interface CommonMapper<T> extends BaseMapper{ public List<T> implementByChild(); } @SqlResource("user") public static interface MyTestUserMapper extends CommonMapper<User>{ } ``` 如上定义的Mapper,当调用MyTestUserMapper.implementByChild方法时候,默认寻找common.md文件 如果想寻找的是user.md文件,则需要使用@InheritMapper注解,调用MyTestUserMapper.implementByChild方法时候,寻找MyTestUserMapper上指定的sql文件 ```java @SqlResource("common") public static interface CommonMapper<T> extends BaseMapper{ @InheritMapper public List<T> implementByChild(); } ```