File was renamed from ltkj-admin/src/main/java/com/ltkj/web/db/DataSourceConfig.java |
| | |
| | | package com.ltkj.web.db; |
| | | package com.ltkj.common.db; |
| | | |
| | | import com.alibaba.druid.pool.DruidDataSource; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import javax.sql.DataSource; |
| | | import java.util.HashMap; |
| | |
| | | //@Configuration |
| | | public class DataSourceConfig { |
| | | |
| | | // 使用代码 |
| | | // try { |
| | | // long id = Long.parseLong(request.getAttribute("id").toString()); |
| | | // DataSourceContextHolder.setDataSourceKey(String.valueOf(id)); |
| | | // dataSourceConfig.addDataSource(String.valueOf(id)); // 确保数据源已注册 |
| | | // if (log.getSize()>50) log.setSize(50); |
| | | // if (log.getLang().equals("zh-cn")) log.setLang("zh"); |
| | | // return serverLogService.getLog(log,id); |
| | | // }finally { |
| | | // DataSourceContextHolder.setDataSourceKey("default"); // 切换回主库 |
| | | // } |
| | | |
| | | private static final String DEFAULT_DATA_SOURCE_KEY = "default"; // 主库的标识 |
| | | private final Map<String, DataSource> dataSourceCache = new HashMap<>(); // 数据源缓存 |
| | | |