referencing configuration.properties outside of the .war

Ikthiander picture Ikthiander · Feb 3, 2011 · Viewed 13.1k times · Source

i want to deploy a war and the war should fetch some properties from outside the war (lets say where the .war file is, that same directory.)

at the moment this is the best solution i have found:

<context:property-placeholder location="file:${user.home}/configuration.properties" ignore-unresolvable="true"/>

but this solution forces me to keep it always in the home directory. i want it to be in the tomcat webapps directory where i deploy my .war. I am only looking for a solution that involves absolute path. if relative path is absolutely impossible, then i will consider an absolute path.

thanks in advance.

Answer

Ikthiander picture Ikthiander · Feb 3, 2011

here is one solution:

<context:property-placeholder 
     location="file:${catalina.home}/webapps/datasource.properties"
     ignore-unresolvable="true"/>

let me know if there is anything better, for example if i can get rid of catalina home reference and make it a more general one somehow.