You actually won't need PropertyPlaceholderConfigurer if you're using @Value.
You could do just the following:
Given a properties file on the classpath at 'com/acme/app/myprops.properties':
Code:
hostname=localhost
foo=a
bar=b
In your XML, declare a util
roperties bean
Code:
<util:properties id="myProps" location="classpath:com/acme/app/myprops.properties"/>
Then, within your classes:
Code:
@Value("#{myProps.hostname}")
public void setHostName(String hostname) {
this.hostname = hostname;
}
Spring EL can resolve any bean by its name. Since the content of your properties file is now available as a Spring-managed java.util.Properties bean named 'myProps', you can just refer to it by name.
I've just added a unit test that captures the scenario above: https://fisheye.springsource.org/cha...k/trunk?cs=874
Also note that in the forthcoming M3 release (drops this week!), you'll be able to use 'regular' ${...} tokens with @Value, and these will resolve using PropertyPlaceholderConfigurer / <context
roperty-placeholder/>. So you've got two options. The ${...} style is processed once and only once, during BeanFactoryPostProcessing, and the #{...} style is evaluated every time a bean is instantiated. So you can think of one as static and the other as dynamic.