【问题标题】:Changing the database at runtime in Grails application在 Grails 应用程序中在运行时更改数据库
【发布时间】:2008-11-18 07:10:56
【问题描述】:

我想知道是否有办法在运行时在 grails 中更改数据库 - 例如,在大多数商业/开源 CMS 中,它们允许将数据库服务器托管在其他地方,您可以在某些配置屏幕中指定地址运行。

既然 grails 使用 DataSource.groovy 配置数据库服务器,如何访问它的内部,并更改数据库 url?还是数据库类型?

【问题讨论】:

    标签: database grails


    【解决方案1】:

    请参阅 Grails 文档中的 [Databases and Environments](http://grails.org/doc/1.0.x/guide/3.%20Configuration.html#3.3.1DataSources and Environments)。

    如果以上内容不能完全满足您的需求,另请参阅[Externalized Configuration](http://grails.org/doc/1.0.x/guide/3.%20Configuration.html#3.4 Externalized Configuration)。

    只要数据库可以通过 JDBC 访问,Grails 并不关心数据库驻留在哪里,因此将数据库服务器放在别处不是问题,只需进行配置即可。

    【讨论】:

    • hhmm,这太棒了 - 我没有注意到 doco 的那部分!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-19
    • 1970-01-01
    相关资源
    最近更新 更多