referencing configuration.properties outside of the .war referencing configuration.properties outside of the .war spring spring

referencing configuration.properties outside of the .war


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.


One solution I can offer is using system property to pass the path to configuration file.

There are 2 levels of properties:

  • java system properties sent using switch -D to JVM and extracted by System.getProperty()
  • OS environment variables that you define on OS level and can access using System.getenv()


Quite a bit late to this party, but I figured I'd post an answer because this question came up first on Google for me. I'm not sure if this worked at the time the question was asked, but as of Spring 3.1, you can do this to use an absolute path:

<context:property-placeholder location="file:///etc/myApp/myApp.conf"/>

Note that there are three forward-slashes. The first two are for the protocol: "file://".