mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
optimize
This commit is contained in:
parent
b80cce4911
commit
283b578989
@ -241,27 +241,10 @@ public class FlexGlobalConfig {
|
|||||||
return defaultConfig;
|
return defaultConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 指定默认全局配置(允许手动。在多源时,方便由注解指定默认源)
|
|
||||||
*
|
|
||||||
* <code><pre>
|
|
||||||
* @Configuration
|
|
||||||
* public class Config{
|
|
||||||
* @Bean(value = "db1", typed = true) //默认
|
|
||||||
* public DataSource db1(@Inject("${demo.db1}") HikariDataSource ds) {
|
|
||||||
* return ds;
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* @Bean("db2")
|
|
||||||
* public DataSource db1(@Inject("${demo.db2}") HikariDataSource ds) {
|
|
||||||
* return ds;
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* </pre></code>
|
|
||||||
*
|
|
||||||
* @param config 全局配置
|
|
||||||
*/
|
|
||||||
public static void setDefaultConfig(FlexGlobalConfig config) {
|
public static void setDefaultConfig(FlexGlobalConfig config) {
|
||||||
|
if (config == null) {
|
||||||
|
throw new NullPointerException("config must not be null.");
|
||||||
|
}
|
||||||
defaultConfig = config;
|
defaultConfig = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +256,6 @@ public class FlexGlobalConfig {
|
|||||||
return globalConfigs.get(environmentId);
|
return globalConfigs.get(environmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static synchronized void setConfig(String id, FlexGlobalConfig config) {
|
public static synchronized void setConfig(String id, FlexGlobalConfig config) {
|
||||||
setConfig(id, config, true);
|
setConfig(id, config, true);
|
||||||
}
|
}
|
||||||
@ -283,11 +265,11 @@ public class FlexGlobalConfig {
|
|||||||
*
|
*
|
||||||
* @param id 环境id
|
* @param id 环境id
|
||||||
* @param config 全局配置
|
* @param config 全局配置
|
||||||
* @param autoDefault 自动指定默认全局配置(在多源时,方便由注解指定默认源)
|
* @param copyToDefault 自动指定默认全局配置(在多源时,方便由注解指定默认源)
|
||||||
*/
|
*/
|
||||||
public static synchronized void setConfig(String id, FlexGlobalConfig config, boolean autoDefault) {
|
public static synchronized void setConfig(String id, FlexGlobalConfig config, boolean copyToDefault) {
|
||||||
//first setConfig,copy the config to default
|
//first setConfig,copy the config to default
|
||||||
if (autoDefault && globalConfigs.isEmpty()) {
|
if (copyToDefault && globalConfigs.isEmpty()) {
|
||||||
|
|
||||||
defaultConfig.setSqlSessionFactory(config.sqlSessionFactory);
|
defaultConfig.setSqlSessionFactory(config.sqlSessionFactory);
|
||||||
defaultConfig.setDbType(config.dbType);
|
defaultConfig.setDbType(config.dbType);
|
||||||
|
|||||||
@ -88,7 +88,7 @@ public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全局配置
|
* 获取全局配置
|
||||||
* */
|
*/
|
||||||
public FlexGlobalConfig getGlobalConfig() {
|
public FlexGlobalConfig getGlobalConfig() {
|
||||||
return globalConfig;
|
return globalConfig;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user