In Spring MVC Hibernate application , when i am trying to use properties file ,which is under src/java/resources , it is throwing below error :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String com.mcb.controller.UserController.strDefaultPage; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'mcbPage.name'
I am using below code to access property value in my controller class:
@Value("${mcbPage.name}")
private String strDefaultPage;
I added bean in my ApplicationContext.xml file for the this property file:
<bean id="mcbProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath*:mcb.properties</value>
<value>file:src/main/resources/mcb.properties</value>
</list>
</property>
</bean>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="properties" ref="mcbProperties" />
</bean>
and my properties file (mcb.properties) resides under src/main/resources. @Autowired is working fine. but when trying to use propert file it is throwing error while starting the server.
Could somebody help me in solving this ?
Update
Use
and then in your Bean