baomidou / dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Apache License 2.0
4.75k stars 1.19k forks source link

日志不输出 #665

Closed lunxian8 closed 3 months ago

lunxian8 commented 3 months ago

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

代码示例:

@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);