zhaowenxuan
2025-03-21 02b4c9fd4c5ff7c77553fd4bf0f07d4b21ae8f09
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.ltkj.db;
 
public class DataSourceContextHolder {
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();
 
    public static void setDataSourceKey(String key) {
        contextHolder.set(key);
    }
 
    public static String getDataSourceKey() {
        return contextHolder.get();
    }
 
    public static void clear() {
        contextHolder.remove();
    }
}