我開始與現有的Grails項目工作,這是一個與外部配置文件涉及的配置文件(Config.groovy中)的部分:Grails的外部配置文件
grails.config.locations = [];
def defaultConfigFile = "${basedir}/configs/BombayConfig.groovy"
def defaultDatasourceFile = "${basedir}/configs/BombayDataSource.groovy"
if(File.separator == "\\") {
defaultConfigFile = defaultConfigFile.replace('/', '\\')
defaultDatasourceFile = defaultDatasourceFile.replace('/', '\\')
}
String PROJECT_NAME = "BOMBAY"
String CONFIG_ENV = "${PROJECT_NAME}_CONFIG_LOCATION"
String DATASOURCE_ENV = "${PROJECT_NAME}_DATASOURCE_LOCATION"
def externalConfig = System.getenv(CONFIG_ENV)
def externalDataSource = System.getenv(DATASOURCE_ENV)
if (externalConfig && new File(externalConfig).isFile()) {
grails.config.locations << "file:" + externalConfig
}
else {
grails.config.locations << "file:" + defaultConfigFile
}
if (externalDataSource && new File(externalDataSource).isFile()) {
grails.config.locations << "file:" + externalDataSource
}
else {
grails.config.locations << "file:" + defaultDatasourceFile
}
我在CONFIGS一些默認的文件文件夾,但是在服務器正在使用的文件駐留在:
/home/someusername/configuration/
它看起來並不像默認路徑,並且沒有指向該路徑作爲配置建議的環境變量。
我也試着尋找一個鏈接到其他配置文件夾的configs文件夾,但沒有找到任何東西。
我迷失在這裏;如何將配置文件指定給Grails?
編輯: 爲了澄清事情,服務器正在運行並運行,我只想弄清楚它是如何從上述指定路徑中獲取配置文件的。
您確定沒有將這些環境變量傳遞給server_(Tomcat?)上的相關進程,即使它們沒有設置在您檢查的任何shell中。通常當我需要設置這樣的東西時,我將環境設置放入Tomcat啓動腳本中。 –
這就是我想念伊恩,他們被設置在劇本中。謝謝! –