使用AbstractRoutingDataSource动态更改数据库模式/目录 [英] Using AbstractRoutingDataSource to dynamically change the database schema/catalog
问题描述
根据本文,您可以使用AbstractRoutingDataSource从Spring框架动态更改应用程序使用的数据源。
但是,使用的数据源由配置而不是编程方式定义。是否有一种方法来配置要在运行时使用的数据源?
此解决方案的可扩展性,即数据源数量的限制? p>
谢谢!
我已经为30个数据源实现了这种方法,目前正在生产环境中运行,没有任何问题。如果你使用JPA,你可以看看我的配置:
According to this article, you can use the AbstractRoutingDataSource from Spring Framework to dynamically change the data source used by the application.
However, the data sources used are defined by configuration, instead of programmatically. Is there a way of configuring the data sources to be used at runtime?
How scalable is this solution, i.e., what are the limitations in number of data sources?
Thanks!
I have implemented this approach for 30 datasources and they are currently running in a Production environment without any issues. If you are using JPA you can have a look at my config:
这篇关于使用AbstractRoutingDataSource动态更改数据库模式/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!