Spring Boot JDBC + MySQL – How to Configure Multiple DataSource

In the previous article we saw how to configure a datasource in a spring boot application,  that’s very straight forward.  In this article I will show you how to configure multiple datasources in spring boot application. Unlike single datasource, in order to create multiple datasources we may need to write little configuration, I will show you how.

Directory Structure

Add Spring Boot JDBC Dependency

Final pom.xml

Add Datasources Information in


If you run the app and hit the URL (this will use test database) : http://localhost:8080/springbootds/getcustInfo

And if you hit this URL (this will use test2 database) : http://localhost:8080/springbootds/testSecondDatasource


You Might Also Like

  ::. About the Author .::

- Full Stack Java/J2EE & UI Web Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


One Response to “Spring Boot JDBC + MySQL – How to Configure Multiple DataSource”
  1. krishna reddy says:

    I just gone through all of your spring boot articles, those are well written. I got understand in one shot of reading. please be post further articles on spring boot.

    Thank you


By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Hibernate Spring Struts
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2018 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.