0、简介1、引入 POM2、实体类3、Mapper 接口4、service 接口5、Impl 实现类6、MySQL 连接参数最后上加如下参数 ==(重要)==7、使用批量插入
0、简介MyBaties-Plus 是 MyBaties 的增强版,MyBaties 有的功能它都有,MyBaties 没有的功能它也有。MP 有许多优点,但是这里我只记录批量插入的方法,好处是大数据量速度相对来说很快,有兴趣的可以自己做下对比。实现步骤如下。
1、引入 POM2、实体类com.baomidou mybatis-plus-boot-starter3.4.3.4
@TableName("t_a")
public class A{}
3、Mapper 接口
public interface AMapperextends baseMapper{}
4、service 接口
public interface IAService extends IService {}
5、Impl 实现类
public class AServiceImpl extends ServiceImpl implements IAService {}
6、MySQL 连接参数最后上加如下参数 (重要)
# &rewriteBatchedStatements=true 告诉 jdbc 要使用批处理 jdbc:mysql://ip:3306/t_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true7、使用批量插入
public class testService {
@Autowired
private IAService aService;
public void test(List list) {
aService.saveBatch(list);
}
}
记录如有不对烦请指出,先行感谢



