Add this to your context
<context:property-placeholder location="${envfile}"/>
This will load the properties file located in $ {envfile}, a variable that you can set with the Java startup parameter in this way
-Denvfile="file:/var/server/environment.properties"
Or maybe in a Tomcat startup script
CATALINA_OPTS=" -Denvfile=file:/var/server/environment.properties"
Values ββcan be restored to your controllers using the Springs Value annotation as follows:
@Values("${myvalue}") private String myValue;
Please note that Spring 3.1 is required for these features, more details here
Good luck
source share