I have an application that runs Spring MVC.
I need it to access 2 different databases in my app (one is a PostgreSQL and the other one is a MySQL database).
How do I configure this using just annotations or application.properties file?
Regards.
I have an application that runs Spring MVC.
I need it to access 2 different databases in my app (one is a PostgreSQL and the other one is a MySQL database).
How do I configure this using just annotations or application.properties file?
Regards.
Here is the example code for having
multiple Database/datasource
onSpring-Boot
I hope it helps!application.properties
DatabaseItemsConfig.java
DatabaseUsersConfig.java
ItemRepository.java
UserRepository.java
Controller.java
Application.java
this is how you set up multiple data sources on spring xml file, here is mine for example, hope it helps
You can also try to define multiple datasources & assign one of them as primary.
Here is the demo code.
The Primary Datasource:
Another Datasource (In my demo, it's sqlserver)
Ref:https://stackoverflow.com/a/27679997/6037575