Closed lunxian8 closed 3 months ago
Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。
JDK Version(required): 1.8.311 SpringBoot Version(required): 2.7.6 dynamic-datasource-spring-boot-starter Version(required): 4.3.0 druid Version(optional): 1.2.21
代码示例:
@DSTransactional
public void syncData(List targets) {
// 查询数据 这一步有sql日志输出
QueryWrapper<Object> qw = Wrappers.query(entity).apply(StringUtils.isNotBlank(applySql), applySql); List<?> entityList = Db.list(qw);
// 把查询的数据保存到各个数据库里 ;下面删除和保存无日志输出了 targets.forEach(target -> { DynamicDataSourceContextHolder.push(target.getId()); for (Tuple2<String, List<?>> tuple2 : syncData) { baseMapper.deleteAllTable(tuple2.getFirst()); Db.saveBatch(tuple2.getSecond()); } DynamicDataSourceContextHolder.clear(); });
}
总结:切换数据源后日志不输出,请问哪里可以配置?注册数据源的石化这里都是打开的:
dataSourceProperty.setLazy(lazy); dataSourceProperty.setP6spy(true);
Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。
Enviroment
JDK Version(required): 1.8.311 SpringBoot Version(required): 2.7.6 dynamic-datasource-spring-boot-starter Version(required): 4.3.0 druid Version(optional): 1.2.21
代码示例:
public void syncData(List targets) {
// 查询数据 这一步有sql日志输出
// 把查询的数据保存到各个数据库里 ;下面删除和保存无日志输出了 targets.forEach(target -> { DynamicDataSourceContextHolder.push(target.getId()); for (Tuple2<String, List<?>> tuple2 : syncData) { baseMapper.deleteAllTable(tuple2.getFirst()); Db.saveBatch(tuple2.getSecond()); } DynamicDataSourceContextHolder.clear(); });
}
总结:切换数据源后日志不输出,请问哪里可以配置?注册数据源的石化这里都是打开的: