java - Spring Boot and Spring Data application with multiple DataSources created in runtime -
i developing spring boot application uses spring data jpa , need connect many different databases e.g. postresql, mysql, ms-sql, mongodb. need create datasources in runtime i.e. user choose these data gui in started application: -driver(one of list), -source, -port, -username, -password. , after writes native sql choosen database , results. read lot of things in stack , spring forums(e.g. abstractroutingdatasource) of these tutorials show how create datasources xml configuration or static definition in java bean. possible create many datsources in runtime? how manage transactions , how create many sessionfactories? possible use @transactional annotation? best method this? can explain me how 'step step'?
hope it's not late answer ;)
i developed module can integrated in spring project. uses meta-datasource hold tenant-datasource connection details. tenant-datasource abstractroutingdatasource used.
here find core implementation using abstractroutingdatasource. https://github.com/dactabird/multitenancy
here example show how integrate it. https://github.com/dactabird/multitenancy-sample in example i'm using h2 embedded db. of course can use whatever want.
feel free modify purposes or ask if questions left!
Comments
Post a Comment