I'm trying to use Grails' built-in mechanism for loading external configuration files (*.groovy and *.properties) outside the deployed WAR file. The documentation implies this is just a case of setting grails.config.locations
with the appropriate classpath:
or file:
paths.
I've configured Config.groovy with:
String externalConfigLocation = System.getProperty("SYSTEM_PROPERTY_KEY")
if (!grails.config.locations || !(grails.config.locations instanceof List)) {
grails.config.locations = []
}
if (classpathExternalConfigLocation) {
String pathToResource = ""file:${basedir}" + File.separator + externalConfigLocation+"""
print "Loading external configuration file: ${pathToResource}
"
grails.config.locations << pathToResource
}
However this hasn't worked, with error messages indicating the file "Does not exist". However, printing the absolute path stored in grails.config.locations
indicates it does. I have tried some combinations:
classpath:configurationFile.properties
file:c:path_to_fileconfigurationFile.properties
c:path_to_fileconfigurationFile.properties
but in all these cases the file can't be found.
Very strange - advise appreciated. Or suggestions on how to debug.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…