集成通用Mapper

本文介绍如何在项目中集成通用Mapper,包括引入必要的依赖、配置插件等步骤,并提及了使用过程中的一些注意事项。

通用Mapper集成

1.引入jar包

<mapper.version>3.0.1</mapper.version>
<persistence-api.version>1.0.2</persistence-api.version>
<dependency>
<groupId>com.github.abel533</groupId>
<artifactId>mapper</artifactId>
<version>${mapper.version}</version>
</dependency>

<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>${persistence-api.version}</version>
</dependency>

2.在mybatis配置生成generatorConfig.xml添加插件

<plugin type="com.github.abel533.generator.MapperPlugin">
<property name="mappers" value="com.github.abel533.mapper.Mapper"/>
</plugin>


说说通用Mapper的坑

通用Mapper在生成的mapper会继承Mapper,所以除了配置扫描的包,还要配置扫描basePackage,还需要配置
mapperScannerConfigurer.setMarkerInterface(com.github.abel533.mapper.Mapper.class);

这种做法沿用了ibatis使用sqlSessionTemplate的思想,并不是很推荐。


说明:其他部分不提供

转载于:https://www.cnblogs.com/nunuAction/p/7063937.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值