Search code examples
spring-bootspring-data-jpaspring-data-mongodb

Can a single Spring boot/Spring data application have repo of Posgres and MongoDB


I am having a need where in a same spring boot application I need to use repo of Spring Data Mongo and Spring data jpa (postgres), during my initial testing I got runtime errors. While I debug more just wanted to check in same Spring Data Application can it have both repos for Postgres and MongoDB ?


Solution

  • Yes, you can have, make sure to add all dependency and create separate repositories for each data connection. I used MongoDB and MySql database it is working fine.