路泰机电科技体检——数据平台后端
zhaowenxuan
2025-08-04 a7b439b5339f65f06d4be5172004051457c5be83
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.example.config.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();
    }
}