If someone wants to achieve this without using @PropertySource
use the ApplicationContextInitializer interface and its satellite, the context context parameter contextInitializerClasses.
add this to web.xml
<context-param>
<param-name>contextInitializerClasses</param-name>
<param-value>com.test.MyInitializer</param-value>
</context-param>
and define your initializer
public class MyInitializer implements ApplicationContextInitializer<ConfigurableWebApplicationContext> {
public void initialize(ConfigurableWebApplicationContext ctx) {
PropertySource ps = new ResourcePropertySource(new ClassPathResource("sample.properties"));
ctx.getEnvironment().getPropertySources().addFirst(ps);
}
}
: Spring 3.1 M1: