Skip to content

Instantly share code, notes, and snippets.

@brianhsu
Created March 2, 2023 06:02
Show Gist options
  • Save brianhsu/f05791fac623ba52e97511860c02c487 to your computer and use it in GitHub Desktop.
Save brianhsu/f05791fac623ba52e97511860c02c487 to your computer and use it in GitHub Desktop.
@Configuration
@Slf4j
public class DataSourceConfig {
@Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource.pws")
public DataSourceProperties pwdDataSourceProperties() {
return new DataSourceProperties();
}
@Bean(name = "pwsDataSource") // As a bean object and named
public DataSource dataSource() {
DataSourceProperties first = pwdDataSourceProperties();
DataSourceProperties second = pwdDataSourceProperties();
return first.initializeDataSourceBuilder().build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment