春天在运行时添加数据源 [英] spring add datasource at runtime
问题描述
我正在使用每个租户策略使用数据库的Spring Boot多租户应用程序.要求是在运行时添加新数据库,这意味着我必须动态创建新的数据源对象.
I am working on a spring boot multi-tenant application with database per tenant strategy. Requirement is that to add new databases at runtime which means I have to create new datasource objects dynamically.
我还查看了Spring的AbstractRoutingDataSource,但需要使用预定义的数据源.因此,我只想知道如何在不重新启动应用程序服务器的情况下添加/删除数据源.
I also looked upon Spring's AbstractRoutingDataSource but in needs pre-defined datasources. So I just want to know how to add/remove datasource without restarting application server.
提前谢谢.
推荐答案
我终于设法使事情顺利进行.对于遇到同样问题的人,只需检查此多租户演示项目.
I finally managed to get things working straight. For someone having same issue, just check this multi-tenant demo project.
这篇关于春天在运行时添加数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!