配置Spring Boot通过@ConditionalOnProperty来控制Configuration是否生效
@Configuration
//如果synchronize在配置文件中并且值为true
@ConditionalOnProperty(name = "synchronize", havingValue = "true")
public class SecondDatasourceConfig {
@Bean(name = "SecondDataSource")
@Qualifier("SecondDataSource")
@ConfigurationProperties(prefix = "")
public DataSource jwcDataSource() {
return ().build();
}
}