我已经设置了一个这样的环境变量:
APP_HOME = "c:\app\app-datasource.properties
在 config.groovy 我做
def ENV_NAME = "APP_HOME"
if(!grails.config.location || !(grails.config.location instanceof List)) {
grails.config.location = []
}
if(System.getenv(ENV_NAME)) {
println "Including configuration file specified in environment: " + System.getenv(ENV_NAME);
grails.config.location << "file:" + System.getenv(ENV_NAME)
} else if(System.getProperty(ENV_NAME)) {
println "Including configuration file specified on command line: " + System.getProperty(ENV_NAME);
grails.config.location << "file:" + System.getProperty(ENV_NAME)
} else {
println "No external configuration file defined."
}
我从网上的帖子中得到这个,我想知道我们是否需要使用grails.config.location
or grails.config.locations
?另外APP_HOME
,我可以将其设置为目录路径(e.g.: c:\apps)
,然后可以将多个属性文件放置在该目录中,而不是直接设置为属性文件,那么如果我多次执行以下操作,它会起作用吗?:
grails.config.locations << "file:" + System.getProperty(ENV_NAME)+ "\app-datasource.properties"
grails.config.locations << "file:" + System.getProperty(ENV_NAME)+ "\app-reporting.properties"
and so on...
提前致谢