问题
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.
来源:https://stackoverflow.com/questions/18629282/grails-multiple-database-for-multiple-client-but-one-source