Reputation: 402
In my config.groovy i have set ..
emailTo="[email protected]"
emailForm="[email protected]"
but i want some flexibility in this. Can I change this while my project is running form property file ? Please help
Upvotes: 1
Views: 1412
Reputation: 122364
I believe there is a plugin to support dynamic reloading of external config files whenever they change, but conceptually if this is data that is supposed to be modifiable at runtime then maybe it would be better to represent it as a domain object and store it in the database.
I use this method on a number of projects, defining a domain class
class AppConfiguration {
String adminEmail
String appTitle
// etc
}
and ensuring there is always exactly one instance in the database, creating an initial instance in BootStrap
if it is not already present. Now anywhere in the app that requires this config data I just do AppConfiguration.list()[0]
I just use dynamic scaffolding for the edit pages, which are restricted to be accessible only to admin users through Spring Security.
Upvotes: 1
Reputation: 35961
Yes, you can use .property
file as well, by default Grails looks for properties at:
${appName}-config.properties
~/.grails/${appName}-config.properties
${appName}.config.location
Just take a look at first few lines of your Config.groovy
, you can put there any other path to your own .properties
See also http://grails.org/doc/2.1.0/guide/conf.html#configExternalized
Upvotes: 1