| | |
| | | return druidProperties.dataSource(dataSource); |
| | | } |
| | | |
| | | @Bean |
| | | @ConfigurationProperties("spring.datasource.druid.cwsj") |
| | | @ConditionalOnProperty(prefix = "spring.datasource.druid.cwsj", name = "enabled", havingValue = "true") |
| | | public DataSource cwsjDataSource(DruidProperties druidProperties) |
| | | { |
| | | DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); |
| | | return druidProperties.dataSource(dataSource); |
| | | } |
| | | |
| | | @Bean(name = "dynamicDataSource") |
| | | @Primary |
| | | public DynamicDataSource dataSource(DataSource masterDataSource) |
| | |
| | | Map<Object, Object> targetDataSources = new HashMap<>(); |
| | | targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); |
| | | setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource"); |
| | | setDataSource(targetDataSources, DataSourceType.CWSJ.name(), "cwsjDataSource"); |
| | | return new DynamicDataSource(masterDataSource, targetDataSources); |
| | | } |
| | | |