数据库中的属性 [英] Properties in the database
问题描述
我想将属性存储在数据库表中,并为在 Config.groovy
中设置的属性设置默认值。例如,我想将一个默认的电子邮件地址放到Config.groovy中:
app.send.report.to ='me @ example.com'
然后可以在数据库表中覆盖它( key
, value
columns ...)。
是否有插件(或grails中的功能)来做到这一点? 动态配置插件。
它将配置属性存储在ConfigProperty域中,并合并来自 Config.groovy
和从数据库使用:
grailsApplication.config.merge(configObject)
您可能需要查看插件源代码。如果插件不适用于您,您可以实现与此类似的功能。
当您有用于编辑配置属性的UI时,此方法非常有用。 $ b
I'd like to store properties in a database tables and have defaults for those properties set in Config.groovy
. For example, I want to put a default email address into Config.groovy:
app.send.report.to = 'me@example.com'
and then be able to override this in a database table (key
, value
columns...).
Is there a plugin (or functionality inside grails) to do this?
There is Dynamic Config Plugin.
It stores config property in ConfigProperty domain and merges properties from Config.groovy
and from database using:
grailsApplication.config.merge(configObject)
You may want to look at the plugin source code. If plugin does not work for you, you can implement something similar to this.
This approach is useful when you have UI for editing config properties.
这篇关于数据库中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!