How to configure multiple datasources programmatically in spring boot?

How to configure multiple datasources programmatically in spring boot?

Add Comment
1 Answer(s)
@Configuration
public class DBConfig {
    @Primary
    @Bean(name = "Primary-db")
    public DataSource primaryDataSource() {
        return connectionFactory().dataSource("Primary-db;
    }
    @Bean(name = "secondary-db")
    public DataSource secondDataSource() {
        return connectionFactory().dataSource("secondary-db");
    }
}
Answered on July 19, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.