Dynamic DataSource Routing
问题 Sorry for my bad English. I wrote implementation for AbstractRoutingDataSource: public class DatabaseRoutingDataSource extends AbstractRoutingDataSource{ @Override protected Object determineCurrentLookupKey() { return DatabaseContextHolder.getDatabaseType(); } } And I created new class for switching between databases: public class DatabaseContextHolder { private static final ThreadLocal<DatabaseType> contextHolder = new ThreadLocal<DatabaseType>(); public static void setDatabaseType