一、该问题的重现步骤是什么?
1. 创建两个数据库 xxx,xxx-logic xxx放的是框架数据表 xxx-logic放的自己的数据表
2. xxx-logic 创建 a,b 两个表并生成相关代码
3.配置数据源master,slave,其中master指向xxx,slave指向xxx-logic
4.在生成的两个表对应的mapper添加注解@DS("slave")
5.a表对应的controller里面的调用a服务对应的getOne接口时能正常切换数据源,但是在b表对应的controller中调用a服务的getOne接口时不能切换数据源。
二、你期待的结果是什么?实际看到的又是什么?



三、你正在使用的是什么产品,什么版本?在什么操作系统上?
mac系统,dev分支
四、请提供详细的错误堆栈信息,这很重要。
五、若有更多详细信息,请在下面提供。
1.注释掉数据权限依赖或者按帖子https://sns.bladex.cn/q-1448.html做
2.引入多数据源插件和配置
#数据源配置 spring: datasource: dynamic: #设置默认的数据源或者数据源组,默认值即为master primary: master datasource: master: url: jdbc:mysql://localhost:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: root password: 12345678 slave: url: jdbc:mysql://localhost:3306/bladex_slave?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: root password: 12345678
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
3.测试多数据源
@RestController
@AllArgsConstructor
@RequestMapping("dynamic")
@Api(value = "多数据源接口", tags = "多数据源")
public class DynamicController {
private IDynamicService dynamicService;
/**
* master列表
*/
@GetMapping("/master-list")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "master列表", notes = "master列表")
public R<List<Notice>> masterList() {
List<Notice> list = dynamicService.masterList();
return R.data(list);
}
/**
* slave列表
*/
@GetMapping("/slave-list")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "slave列表", notes = "slave列表")
public R<List<Notice>> slaveList() {
List<Notice> list = dynamicService.slaveList();
return R.data(list);
}
}@Service
public class DynamicServiceImpl extends BaseServiceImpl<NoticeMapper, Notice> implements IDynamicService {
@Override
public List<Notice> masterList() {
return this.list();
}
@Override
@DS("slave")
public List<Notice> slaveList() {
return this.list();
}
}public interface IDynamicService extends BaseService<Notice> {
/**
* master数据源的列表
*
* @return
*/
List<Notice> masterList();
/**
* slave数据源的列表
*
* @return
*/
List<Notice> slaveList();
}
