
MyBaties-Plus 是 MyBaties 的增强版,MyBaties 有的功能它都有,MyBaties 没有的功能它也有。MP 有许多优点,但是这里我只记录批量插入的方法,好处是大数据量速度相对来说很快,有兴趣的可以自己做下对比。实现步骤如下。
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3.4</version>
</dependency>@TableName("t_a")
public class A{}public interface AMapperextends BaseMapper<A>{}public interface IAService extends IService<A> {}public class AServiceImpl extends ServiceImpl<AMapper, A> implements IAService {}# &rewriteBatchedStatements=true 告诉 jdbc 要使用批处理
jdbc:mysql://ip:3306/t_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=truepublic class testService {
@Autowired
private IAService aService;
public void test(List<A> list) {
aService.saveBatch(list);
}
}记录如有不对烦请指出,先行感谢
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。