spring.datasource.url = jdbc:mysql://xxxxxxxx:xxxx/xxxxx?useSSL=false&useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoReconnect=true
入口下加@EnableTransactionManagement
@SpringBootApplication
@EnableTransactionManagement
service实现类下加
@Service
@Transactional
 VALUES (:id,:name,:age)”;
List uparChnMulMinList = (List) map.get(“uparChnMulMinList”);
SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(uparChnMulMinList.toArray());
namedParameterJdbcTemplate.batchUpdate(sql, batch);
自定义的list:List
SqlParameterSourceUtils导入这个直接用,调用这个方法createBatch();
开启数据空批量配置:rewriteBatchedStatements=true
开启事务:@EnableTransactionManagement ,@Transactional
可以一试。