I know it's possible to read in values from the grails-app/conf/Config.groovy but i was wondering if it is possible to write values as well?
something as simple as this doesn't seem to actually change the value in the Config.
def oldValue = grailsApplication.config.my.value
assert oldValue == "oldValue"
def newValue = "newValue"
grailsApplication.config.my.value = newValue
assert newValue == grailsApplication.config.my.value
I would like to use this as a way to store some values outside of a database without having to load up another properties file.
That's probably not going to be practical if I understand you correctly. You're really dealing with the compiled Config.class at runtime. Do you really want to check out Config.groovy from your VCS, modify it, check it back in, recompile it, and mess around with the Classloader to reload it? The only way I have found to do this is by externalizing their properties a database or file and managing state at runtime to deal with updates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With