2017-01-20 51 views
0

當前我正在嘗試爲每個ip設置配置文件,我的應用程序正在運行。grails多個服務器的不同配置文件

這裏是我的Config.groovy的一部分:

grails.config.locations = [ 
    "file:web-app/WEB-INF/conf/${InetAddress.getLocalHost().getHostAddress()}.groovy", 
    "file:web-app/WEB-INF/conf/dataSource/${InetAddress.getLocalHost().getHostAddress()}.properties" 
] 

但在Tomcat不是因爲沒有文件夾web-app,所以我補充說,本地工作:

"file:WEB-INF/conf/${InetAddress.getLocalHost().getHostAddress()}.groovy", 
"file:WEB-INF/conf/dataSource/${InetAddress.getLocalHost().getHostAddress()}.properties" 

但仍然不工作。

我怎樣才能讓tomcat正確加載配置文件?

回答

0

當你卡塔利娜起tomcat選擇採用:

配置位置外部配置 - 稱爲Config.groovy中

* JAVA_OPTS="$JAVA_OPTS -DCONFIGLOC=conf/" 
* now it will look for {tomcatbase}/conf/{appname}/{appname}Config.groovy 

然後在您的Config.groovy

if (System.getProperty('CONFIGLOC')) { 
    externalConfigPath='file:'+System.getProperty('CONFIGLOC')+File.separator+appName+File.separator 
}