1 2 3 4 5 6 7 8 9 10 11 12
package com.zteits.job.config.datasource; import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; /** * 动态数据源(需要继承AbstractRoutingDataSource) */ public class DynamicDataSource extends AbstractRoutingDataSource { protected Object determineCurrentLookupKey() { return DatabaseContextHolder.getDatabaseType(); } }