Home Spring Boot Configure and Use Two DataSources
Reply: 0

Spring Boot Configure and Use Two DataSources

user1037 Published in July 23, 2018, 1:35 pm

I am new to Spring and Spring Boot. How would one go about to configure and use two data sources.

For example here is what I have for the first data source.


#first db
spring.datasource.url = [url]
spring.datasource.username = [username]
spring.datasource.password = [password]
spring.datasource.driverClassName = oracle.jdbc.OracleDriver

#second db ...

Application class

public class SampleApplication {
private static final Logger logger = LoggerFactory.getLogger(SampleApplication.class);

public static void main(String[] args) {
    SpringApplication.run(SampleApplication.class, args);

SampleRepository repo;

public void testDriving(){
    logger.debug(repo.findSomeSample("id", "other"));

How do I modify application.properties to add another data source? How do I autowire it to be used by a different repo?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.380339 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO