Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write to config.groovy

Tags:

grails

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.

like image 585
Michael J. Lee Avatar asked Feb 22 '26 00:02

Michael J. Lee


1 Answers

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.

like image 142
proflux Avatar answered Feb 27 '26 09:02

proflux