Grails在运行时改变数据源 [英] Grails changing datasource at runtime
问题描述
如何在数据源
用户登录后更改datasouce(持久性配置文件)应该在应用程序启动时加载。
是否有可能?
注意: strong>我想在运行时一次将某个域的数据源更改为另一个数据源。
您可以在 DataSource.groovy
文件中映射多个数据源并且您可以创建多个有才华的域类,然后您可以在运行时在这些数据源之间执行任何 CRUD
操作。
参考文献
- http://www.jellyfishtechnologies.com/configure-multiple-datasources-in-grails/
- http://www.jellyfishtechnologies.com/querying -on-multiple-datasource-in-grails /
- http://grails.org/doc/2.2.1/guide/conf.html#multipleDatasources
I was asked to implement a logic for having separate domains for a separate user (assuming he will have his own database) means all the domains will be mapped to different database at runtime. Sounds silly i know
How can i change the datasouce(persistence configuration file) after logIn of user while datasource
are supposed to load at startup time of application.
Is it possible somehow?
NOTE: I want to change datasource of some domain to another datasource at runtime one at a time.
You can map multiple data sources in your DataSource.groovy
file and you can create multi talented domain classes and then you can perform any CRUD
operations among these data sources at runtime.
References
- http://www.jellyfishtechnologies.com/configure-multiple-datasources-in-grails/
- http://www.jellyfishtechnologies.com/querying-on-multiple-datasource-in-grails/
- http://grails.org/doc/2.2.1/guide/conf.html#multipleDatasources
这篇关于Grails在运行时改变数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!