I'm trying to use an environment variable inside a Spring property file but it doesn't seem to work
where the app is running
export TEST_VAR=hello
myapp.properties
test.variable=${TEST_VAR}
enter code here
But when I test, the test.variable doesn't translate to hello but stays ${TEST_VAR}.
How can I get Env variable from within that file?
I load the property file this way
<bean id="props" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="singleton" value="true" />
<property name="ignoreResourceNotFound" value="false" />
<property name="locations">
<list>
<value>classpath:myapp.properties</value>
<value>file://#{systemProperties['myApp.configurationFile']}</value>
</list>
</property>
</bean>
<bean class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer">
<property name="properties" ref="props" />
</bean>
<bean id="properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties" ref="props" />
</bean>
myApp.configurationFile is a system variable I pass when tomcat starts up through -DmyApp.configurationFile=...