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.
Provide the file name using context param or java system parameter. But, it is again property file location is war dependent. You should change war file to change propert file location. If i am correct the requirement was to change the props in the file , not the file as such.
It doesn't "go in Tomcat". It goes in the web application (WAR). The best place to put a properties file would be in the webapp's WEB-INF/classes directory, which is part of the application classpath.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With