|
|
|
@ -20,17 +20,17 @@ import java.util.Map;
|
|
|
|
|
@Configuration
|
|
|
|
|
@EnableTransactionManagement
|
|
|
|
|
public class DataSourceConfiguration {
|
|
|
|
|
@Value("${spring.datasource.type}")
|
|
|
|
|
@Value("${app.datasource.type:'com.alibaba.druid.pool.DruidDataSource'}")
|
|
|
|
|
private Class<? extends DataSource> dataSourceType;
|
|
|
|
|
|
|
|
|
|
@Bean(name = "masterDataSource")
|
|
|
|
|
@ConfigurationProperties(prefix = "spring.datasource.master")
|
|
|
|
|
@ConfigurationProperties(prefix = "app.datasource.master")
|
|
|
|
|
public DataSource masterDataSource() {
|
|
|
|
|
return DataSourceBuilder.create().type(dataSourceType).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean(name = "slaveDataSource")
|
|
|
|
|
@ConfigurationProperties(prefix = "spring.datasource.slave")
|
|
|
|
|
@ConfigurationProperties(prefix = "app.datasource.slave")
|
|
|
|
|
public DataSource slaveDataSource() {
|
|
|
|
|
return DataSourceBuilder.create().type(dataSourceType).build();
|
|
|
|
|
}
|
|
|
|
|