I have a properties file which I would like loaded in to System Properties so that I can access it via System.getProperty("myProp")
. Currently, I'm trying to use the Spring <context:propert-placeholder/>
like so:
<context:property-placeholder location="/WEB-INF/properties/webServerProperties.properties" />
However, when I try to access my properties via System.getProperty("myProp")
I'm getting null
. My properties file looks like this:
myProp=hello world
How could I achieve this? I'm pretty sure I could set a runtime argument, however I'd like to avoid this.
Thanks!
In Spring 3 you can load system properties this way:
<bean id="systemPropertiesLoader"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" value="#{@systemProperties}" />
<property name="targetMethod" value="putAll" />
<property name="arguments">
<util:properties location="file:///${user.home}/mySystemEnv.properties" />
</property>
</bean>
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