修改:现场多数据源问题优化
This commit is contained in:
@@ -32,9 +32,6 @@ public class DatabasePlugin implements Interceptor {
|
||||
|
||||
private static final String REGEX = ".*insert\\u0020.*|.*delete\\u0020.*|.*update\\u0020.*";
|
||||
|
||||
// 第二个数据源的Mapper包名(必须和@MapperScan的basePackages一致)
|
||||
private static final String SECOND_MAPPER_PACKAGE = "com.sdm.outbridge.dao";
|
||||
|
||||
private static final Map<String, DBTypeEnum> cacheMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
@@ -44,12 +41,6 @@ public class DatabasePlugin implements Interceptor {
|
||||
if (!synchronizationActive) {
|
||||
Object[] objects = invocation.getArgs();
|
||||
MappedStatement ms = (MappedStatement) objects[0];
|
||||
// 获取当前Mapper的全类名(格式:com.sdm.outbridge.dao.XXXMapper.XXXMethod)
|
||||
String mapperId = ms.getId();
|
||||
// 判断是否是第二个数据源的Mapper:如果是,直接执行,不执行后续的数据源切换逻辑
|
||||
if (mapperId.startsWith(SECOND_MAPPER_PACKAGE)) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
DBTypeEnum databaseType = null;
|
||||
|
||||
if ((databaseType = cacheMap.get(ms.getId())) == null) {
|
||||
|
||||
Reference in New Issue
Block a user