java - In a Spring MVC Hibernate application when using properties file throwing error? -


in spring mvc hibernate application , when trying use properties file ,which under src/java/resources , throwing below error :

org.springframework.beans.factory.beancreationexception: error creating bean name 'usercontroller': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private java.lang.string com.mcb.controller.usercontroller.strdefaultpage; nested exception java.lang.illegalargumentexception: not resolve placeholder 'mcbpage.name' 

i using below code access property value in controller class:

@value("${mcbpage.name}")  private string strdefaultpage; 

i added bean in applicationcontext.xml file 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 properties file (mcb.properties) resides under src/main/resources. @autowired working fine. when trying use propert file throwing error while starting server.
me in solving ?

update use

<util:properties id="mcbpage" location="classpath:mcb.properties"/> 

and in bean

private @value("#{mcbpage['name']}") string strdefaultpage; 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -