Spring JPA PostgreSQL + MongoDB -


starting spring example accessing mongodb data rest (https://spring.io/guides/gs/accessing-mongodb-data-rest/) i'd integrate postgresql data source , link mongodb repository.
by switching mongorepository jparepository , accordingly changing application.properties file i've been able pass mongodb postgresql , viceversa, having 1 active data source @ time.

application.properties when using mongodb

spring.data.mongodb.port=27017 spring.data.mongodb.uri=mongodb://localhost/ spring.data.mongodb.database=mymongodb_db spring.data.mongodb.repositories.enabled=true 


application.properties when using postgresql

spring.datasource.driverclassname=org.postgresql.driver spring.datasource.url=jdbc:postgresql://localhost:5432/mypostgresql_db spring.datasource.username=me spring.datasource.password=mysupersecretpassword  spring.jpa.database-platform=org.hibernate.dialect.postgresqldialect spring.jpa.generate-ddl=true spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=create 

is there way configure spring (with annotation-only way) link 2 data sources same repository when access rest web service via http both mongodb , postgresql changed in same way?

i googled around , found spring cross-store support (http://docs.spring.io/spring-data/mongodb/docs/1.5.5.release/reference/html/mongo.cross.store.html) uses xml application configuration , aspectj, there simpler way accomplish this?

in chapter can find answer - (spring-boot manual - use spring data jpa , mongo repositories)


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -