【问题标题】:Is it possible to read and write to different datasource URLs in Grails 3?是否可以在 Grails 3 中读取和写入不同的数据源 URL?
【发布时间】:2018-11-05 08:53:20
【问题描述】:

能否将 Grails 3 应用程序配置为针对只读副本 MySQL 数据库执行搜索查询,并写入原始主数据库?

【问题讨论】:

    标签: hibernate grails groovy grails-orm


    【解决方案1】:

    您可以在一个域类中配置多个数据源

    static mapping = {
        datasources(['datasourceA', 'datasourceB']) 
    }
    

    稍后,您可以在读取方法中手动使用“datasourceA”,在写入方法中使用“datasourceB”。

    链接:http://guides.grails.org/grails-multi-datasource/guide/index.html

    【讨论】:

      【解决方案2】:

      嗨,我的公司使用 grails 和 aurora mysql - 我们在 grails 项目中设置了 2 个数据源 阅读或搜索时,我们将使用阅读器数据源 如果我们真的需要插入或更新数据,我们会从 writer 数据源中按 id 选择并写入/更新它

      【讨论】:

        猜你喜欢
        • 2012-06-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-22
        • 1970-01-01
        • 2015-06-26
        • 2017-04-21
        • 2015-03-15
        相关资源
        最近更新 更多