grails-用于多个客户端的多个数据库,但是一个源 [英] grails - multiple database for multiple client but one source

查看:59
本文介绍了grails-用于多个客户端的多个数据库,但是一个源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将多个数据库用于多个客户端但只有一个来源.有什么办法可以更改DataSources.groovy文件?

how to use multiple database for multiple client but one source. is there any way to change DataSources.groovy file?

推荐答案

是的,这是可能的.只需将dataSource复制到dataSource文件的顶部并重命名即可(例如datasource2).然后在开发,测试和生产中复制dataSource.用相同的名称重命名新的数据源.

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.

现在,您可以使用与dataSource相同的方式来使用dataSource2了.

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)
    }
}

使用gorm时,请在多个数据源此处支持一章.

When using gorm take a look here at Multiple Data Sources Support chapter.

这篇关于grails-用于多个客户端的多个数据库,但是一个源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆