properties - When does grails.config.locations get processed in Grails? -
I am using grails 1.2.1 and the external configuration file for the war file for my application I want to specify. I understand with documentation that the proper way to do this is to specify
grails.config.locations
list in the Config.groovy file. When I do this, however, the properties that should be set are not available for the program (for example, datasource groovy). When are these properties set?
I would like to load external property files & amp; Then, before making them available for the rest of the program, check some parameters on them. I also want to use these parameter values to set up my logging and data sources.
When the above approach does not work, I also tried to manually load something by doing something like this:
list location = [] def systemConfig = System.getenv (ENV_NAME) def cmdlineConfig = System.getProperty (ENV_NAME) if (systemConfig) {println "contains the configuration file specified in the environment:" + systemConfig; Places & lt; & Lt; SystemConfig} if (cmdlineConfig) {println "with the configuration file specified on the command line:" + cmdlineConfig; Places & lt; & Lt; CmdlineConfig} if (! SystemConfig & amp; cmdlineConfig) println "Warning: no external configuration file is defined." Locations.each {string location - & gt; File f = new file (folk) if (! F.exists ()) println "Warning: file $ {f.absolutePath} not found" other {try {def configSupport = null} (loc.endsWith ('properties')) {Property property = new properties (); Props.load (f.newReader ()); Println "Parsed Property File: $ Props" configSupport = new ConfigSlurper (). Parse (props)} and configSupport = new ConfigSlurper (). Parse (f.toURI (.) ToURL ()) configSupport assert! = Null println "Loaded $ {Loc}: $ configSupport" grails.config = grails.config.merge (configSupport) println "config is now: $ {grails.config}"} hold (exception before) {println "error: $ Could not parse the location: $ Ex.message "}}}
While grails.config was set up correctly, which was not reflected by the rest of the code. Apart from this, this is obviously wrong because I should be able to refer to grails.Somepropname instead of grails.config.grails.somepropname. In essence, I am justified in some way to inject some qualities with my war file and their values.
Thanks,
Gene
Comments
Post a Comment