I am trying to build a spring 3.0 application version 3.1.0.RELEASE , where i want to read from a property file and using the @Value annotation read from it in my Component class. For this the changes i made: in mvc-dispatcher-servlet.xml:
<context:property-placeholder location="classpath:mediamonitoring.properties"/>
Component class:
@Component
public class SomeHelper {
@Value("${baseUri}")
private String baseUri;
public String getBaseUri() {
return baseUri;
}
public void setBaseUri(String baseUri) {
this.baseUri = baseUri;
}
}
Property:
baseUri:http://localhost:8080/
and i have wired this helper class to a @service class using the @Autowired annotation. When i build and deploy the application i get the following error:
java.lang.IllegalArgumentException: Could not resolve placeholder 'baseUri'
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
Is there anything which i am missing because i just followed the standard proceedure.
Appreciate any help in advance.
-Vaibhav