Access and use Java Properties in Spring Context file

This seems like such a simple thing to do, and yet finding a nice simple example online was a real bear (A BEAR!!! actually). So here is my example so the next person will have an easier time of it.

Add properties to your properties file:

[my.properties]

button.icon.search=”com/example/resorces/search.gif”
button.text.search=”Search”

Load the properties file inside the context file:

<bean
class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
<property name=”locations”>
<value>classpath:path/in/cp/my.properties</value>
</property>
</bean>

Access properties from the properties file when setting properties of a bean:

<bean id=”searchButtonBean” init-method=”init” class=”javax.swing.JButton”>
<property name=”text”>
<value>${button.text.search}</value>
</property>
<property name=”buttonIcon” value=”${button.icon.search}”/>
</bean>