| | |
| | | * |
| | | * @author ltkj |
| | | */ |
| | | @Configuration |
| | | //@Configuration |
| | | @Slf4j |
| | | public class DruidConfig { |
| | | |
| | |
| | | private String dbName; |
| | | |
| | | |
| | | @Bean |
| | | // @Bean |
| | | // @ConfigurationProperties("spring.datasource.druid.master") |
| | | public DataSource masterDataSource(DruidProperties druidProperties) { |
| | | DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); |
| | |
| | | return druidProperties.dataSource(dataSource); |
| | | } |
| | | |
| | | @Bean |
| | | // @Bean |
| | | // @ConfigurationProperties("spring.datasource.druid.slavehis") |
| | | // @ConditionalOnProperty(prefix = "spring.datasource.druid.slavehis", name = "enabled", havingValue = "true") |
| | | public DataSource slaveHisDataSource(DruidProperties druidProperties) { |
| | |
| | | return druidProperties.dataSource(dataSource); |
| | | } |
| | | |
| | | @Bean |
| | | // @Bean |
| | | // @ConfigurationProperties("spring.datasource.druid.slavelis") |
| | | // @ConditionalOnProperty(prefix = "spring.datasource.druid.slavelis", name = "enabled", havingValue = "true") |
| | | public DataSource slaveDataLisSource(DruidProperties druidProperties) { |
| | |
| | | return druidProperties.dataSource(dataSource); |
| | | } |
| | | |
| | | @Bean |
| | | // @Bean |
| | | // @ConfigurationProperties("spring.datasource.druid.slavepacs") |
| | | // @ConditionalOnProperty(prefix = "spring.datasource.druid.slavepacs", name = "enabled", havingValue = "true") |
| | | public DataSource slaveDataPacsSource(DruidProperties druidProperties) { |
| | |
| | | return druidProperties.dataSource(dataSource); |
| | | } |
| | | |
| | | @Bean |
| | | // @Bean |
| | | // @ConfigurationProperties("spring.datasource.druid.slavepacs") |
| | | // @ConditionalOnProperty(prefix = "spring.datasource.druid.slavepacs", name = "enabled", havingValue = "true") |
| | | public DataSource slaveDataWsSource(DruidProperties druidProperties) { |
| | |
| | | } |
| | | |
| | | |
| | | @Bean(name = "dynamicDataSource") |
| | | @Primary |
| | | // @Bean(name = "dynamicDataSource") |
| | | // @Primary |
| | | public DynamicDataSource dataSource(DataSource masterDataSource) { |
| | | Map<Object, Object> targetDataSources = new HashMap<>(); |
| | | targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); |
| | |
| | | * 去除监控页面底部的广告 |
| | | */ |
| | | @SuppressWarnings({"rawtypes", "unchecked"}) |
| | | @Bean |
| | | @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") |
| | | // @Bean |
| | | // @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") |
| | | public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) { |
| | | // 获取web监控页面的参数 |
| | | DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); |