public class MultiDataSource extends AbstractRoutingDataSource {
private static final ThreadLocal<String> dataSourceKey = new InheritableThreadLocal<>();
public static void setCurrentDataSource(String dataSource)
{
dataSourceKey.set(dataSource);
}
public static String getDsKey(){
return dataSourceKey.get();
}
@Override
protected Object determineCurrentLookupKey() {
return dataSourceKey.get();
}
}
MultiDataSource.setCurrentDataSource(DataSourceKey.DAP);