2017-09-14 108 views
0

我很難爲tomcat 8的RedHat環境設置JAVA_OPTS。我需要在tomcat安裝目錄之外加載屬性。 文件夾結構:JAVA_OPTS for RedHat

----/home/tomcat -----/apache-tomcat-8 -----/remoteProperties

我想要加載從遠程屬性文件夾的屬性。

這裏是setenv.sh文件內容:

JAVA_OPTS="$JAVA_OPTS -DPropertyPath=/home/tomcat/remoteProperties/collections"

部署我的war文件看來這個路徑沒有正確設置後:

FileNotFoundExcetpion /home/tomcat/apache-tomcat-8.0.41/bin/home/tomcat/remoteProperties/collections/properties/logging/logback.xml

只要我更改setenv.sh的內容並使用相對路徑而不是絕對路徑:

JAVA_OPTS="$JAVA_OPTS -DPropertyPath=../../remoteProperties/collections"

它按預期工作。可以在JAVA_OPTS中設置絕對路徑嗎?謝謝!

回答

0

在調試應用程序後,我注意到FileSystemResourceLoader spring class用於獲取一些資源。然後我在文檔中看到,在使用絕對路徑時,必須將前綴file:。然後,我只需要將setenv.sh腳本的內容更改爲:

JAVA_OPTS="$JAVA_OPTS -DPropertyPath=file:/home/tomcat/remoteProperties/collections"