1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package com.zteits.job.config.datasource; /** * 作用: * 1、保存一个线程安全的DatabaseType容器 */ public class DatabaseContextHolder { private static final ThreadLocal<DatabaseType> contextHolder = new ThreadLocal<>(); public static DatabaseType getDatabaseType(){ return contextHolder.get(); } public static void setDatabaseType(DatabaseType type) { contextHolder.set(type); } }