@Configuration @PropertySource(value="classpath:datasource_single.properties") @PropertySource(value="classpath:datasource_first.properties") @PropertySource(value="classpath:datasource_second.properties") public class DataSourceConfig extends Object
| 构造器和说明 |
|---|
DataSourceConfig() |
| 限定符和类型 | 方法和说明 |
|---|---|
DynamicDataSource |
dynamicDataSource()
Define dynamic primary data source
|
DataSource |
firstDataSource()
Define dynamic data source(first)
|
DataSource |
secondDataSource()
Define dynamic data source(second)
|
DataSource |
singleDataSource()
Define single data source
|
org.springframework.jdbc.datasource.DataSourceTransactionManager |
transactionManager()
Define transaction manager
|
@ConditionalOnProperty(value="datasource.single",
matchIfMissing=false)
@Bean(name="dataSource")
@ConfigurationProperties(value="datasource")
public DataSource singleDataSource()
@ConditionalOnProperty(value={"datasource.dynamic","datasource.first.url"},
matchIfMissing=false)
@Bean(name="firstDataSource")
@ConfigurationProperties(value="datasource.first")
public DataSource firstDataSource()
@ConditionalOnProperty(value={"datasource.dynamic","datasource.second.url"},
matchIfMissing=false)
@Bean(name="secondDataSource")
@ConfigurationProperties(value="datasource.second")
public DataSource secondDataSource()
@ConditionalOnProperty(value="datasource.dynamic",
matchIfMissing=false)
@Bean(name="dataSource")
@Primary
public DynamicDataSource dynamicDataSource()
@ConditionalOnProperty(value="datasource.dynamic",
matchIfMissing=false)
@Bean
public org.springframework.jdbc.datasource.DataSourceTransactionManager transactionManager()
Copyright © 2017. All rights reserved.