Commit 8e3d76d0 by s_guodong

修改数据库配置

parent 1da7771f
...@@ -20,76 +20,14 @@ import java.util.HashMap; ...@@ -20,76 +20,14 @@ import java.util.HashMap;
@Configuration @Configuration
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}) @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
public class DataSourceConfiguration { public class DataSourceConfiguration {
/**
* 数据源1
*/
@Bean(name = "datasource1")
@Qualifier("datasource1")
@ConfigurationProperties(prefix = "spring.datasource1")
public DruidDataSource datasource1() {
return new DruidDataSource();
}
/**
* 数据源2
*/
@Bean(name = "datasource2")
@Qualifier("datasource2")
@ConfigurationProperties(prefix = "spring.datasource2")
public DruidDataSource datasource2() {
return new DruidDataSource();
}
/**
* 数据源eibs
*/
@Bean(name = "eibs")
@Qualifier("eibs")
@ConfigurationProperties(prefix = "spring.eibs")
public DruidDataSource eibs() {
return new DruidDataSource();
}
/**
* 数据源swd
*/
@Bean(name = "swd")
@Qualifier("swd")
@ConfigurationProperties(prefix = "spring.swd")
public DruidDataSource swd() {
return new DruidDataSource();
}
/**
* 数据源fxd
*/
@Bean(name = "fxd")
@Qualifier("fxd")
@ConfigurationProperties(prefix = "spring.fxd")
public DruidDataSource fxd() {
return new DruidDataSource();
}
/**
* 数据源erd
*/
@Bean(name = "erd")
@Qualifier("erd")
@ConfigurationProperties(prefix = "spring.erd")
public DruidDataSource erd() {
return new DruidDataSource();
}
/** /**
* 数据源ryd * 数据源ipsnew
*/ */
@Bean(name = "ryd") @Bean(name = "ipsnew")
@Qualifier("ryd") @Qualifier("ipsnew")
@ConfigurationProperties(prefix = "spring.ryd") @ConfigurationProperties(prefix = "spring.ipsnew")
public DruidDataSource ryd() { public DruidDataSource ipsnew() {
return new DruidDataSource(); return new DruidDataSource();
} }
...@@ -99,15 +37,9 @@ public class DataSourceConfiguration { ...@@ -99,15 +37,9 @@ public class DataSourceConfiguration {
public DataSource dynamicDataSource() { public DataSource dynamicDataSource() {
DynamicDataSource dynamicDataSource = new DynamicDataSource(); DynamicDataSource dynamicDataSource = new DynamicDataSource();
dynamicDataSource.myMap = new HashMap<>(); dynamicDataSource.myMap = new HashMap<>();
dynamicDataSource.myMap.put("datasource1", datasource1()); dynamicDataSource.myMap.put("ipsnew", ipsnew());
dynamicDataSource.myMap.put("datasource2", datasource2());
dynamicDataSource.myMap.put("eibs", eibs());
dynamicDataSource.myMap.put("swd", swd());
dynamicDataSource.myMap.put("fxd", fxd());
dynamicDataSource.myMap.put("erd", erd());
dynamicDataSource.myMap.put("ryd", ryd());
dynamicDataSource.setTargetDataSources(dynamicDataSource.myMap); dynamicDataSource.setTargetDataSources(dynamicDataSource.myMap);
dynamicDataSource.setDefaultTargetDataSource(eibs()); dynamicDataSource.setDefaultTargetDataSource(ipsnew());
DynamicDataSourceContextHolder.dataSourceIds.addAll(dynamicDataSource.myMap.keySet()); DynamicDataSourceContextHolder.dataSourceIds.addAll(dynamicDataSource.myMap.keySet());
return dynamicDataSource; return dynamicDataSource;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment