这里我列举了mybatis和MyBatis-Plus常用的五种批量插入的方式,进行了详细的总结归纳。 一、准备工作 导入pom.xml依赖 Mysql mysql-connector-java runtime or
这里我列举了mybatis和MyBatis-Plus常用的五种批量插入的方式,进行了详细的总结归纳。
导入pom.xml依赖
Mysql mysql-connector-java runtime org.mybatis.spring.boot mybatis-spring-boot-starter 2.2.2 com.baomidou mybatis-plus-boot-starter 3.5.2 org.projectlombok lombok true
配置yml文件
server: port: 8080 spring: datasource: username: mysql用户名 passWord: mysql密码 url: jdbc:mysql://localhost:3306/数据库名字?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC driver-class-name: com.mysql.cj.jdbc.Driver mybatis: mapper-locations: classpath:mapping Integer insertBatchSomeColumn(Collection entityList);}
编写UserMapper接口
@Mapperpublic interface UserMapper extends EasyBaseMapper { }
单元测试结果:一万条数据总耗时:575ms
以上就是我对目前MyBatis常用的批量插入方法的总结
--结束END--
本文标题: MyBatis批量插入的五种方式
本文链接: https://www.lsjlt.com/news/415472.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-12
2024-05-12
2024-05-12
2024-05-12
2024-05-12
2024-05-12
2024-05-12
2024-05-11
2024-05-11
2024-05-11
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0