Create a PropertyPlaceholderConfigurer
for Spring (Refer to the API for options).
Example:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="searchSystemEnvironment" value="true"/>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath:build.properties</value>
<value>classpath:other.properties</value>
</list>
</property>
</bean>
Assuming you have a property file.path
in the property file and you are using component scanning you can then use:
@Value("file.path") private String filePath;
That will then be populated with the value of file.path
in the property file (if the bean is created by Spring)
Or if you are creating your beans in XML:
<bean class="yourClassName">
<property name="filePath" value="${file.path} />
</bean>