how to use multiple database for multiple client but one source. is there any way to change DataSources.groovy file?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, this is possible. Just copy your dataSource at the top of your dataSource file and rename it (eg datasource2). Then copy the dataSource in the development, test and production. Rename the new dataSources with the same name.
Now you are ready to use your dataSource2 with the same way as you use dataSource.
class MySercise {
def dataSource2
def myMethod() {
def sql = new Sql(dataSource2)
}
}
When using gorm take a look here at Multiple Data Sources Support chapter.