java - Spring MVC 3.2.8: Reading from Properties file -


i have application based in spring web model-view-controller (mvc) framework jsp (mvc 3.2.8 application running in weblogic)

i have bean defined in applicationcontext.xml:

<bean id="applicationproperties" class="org.springframework.beans.factory.config.propertiesfactorybean">             <property name="locations">                 <list><value>classpath:resources/config/application.properties</value></list>             </property>  </bean> 

this in class:

@autowired private  properties applicationproperties; .. applicationproperties.getproperty("key") 

but got null value reading property

i tried

@value("#{applicationproperties['key']}") private  string key; 

with result:

org.springframework.beans.factory.beancreationexception: error creating bean name 'criteriaservice': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private java.lang.string com.devices.services.impl.criteriaserviceimpl.emailnotificationperiodindays; nested exception org.springframework.beans.factory.beanexpressionexception: expression parsing failed; nested exception org.springframework.expression.spel.spelevaluationexception: el1008e:(pos 0): field or property 'applicationproperties' cannot found on object of type 'org.springframework.beans.factory.config.beanexpressioncontext'     @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:289)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1146)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:519)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:458)     @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:296)     @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:223)     @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:293)     @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:194)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:628)     @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:932)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:479)     @ org.springframework.test.abstractsinglespringcontexttests.createapplicationcontext(abstractsinglespringcontexttests.java:216)     @ org.springframework.test.abstractsinglespringcontexttests.loadcontextlocations(abstractsinglespringcontexttests.java:192)     @ org.springframework.test.abstractsinglespringcontexttests.loadcontext(abstractsinglespringcontexttests.java:172)     @ org.springframework.test.abstractspringcontexttests.getcontext(abstractspringcontexttests.java:133)     @ org.springframework.test.abstractsinglespringcontexttests.setup(abstractsinglespringcontexttests.java:101)     @ junit.framework.testcase.runbare(testcase.java:132)     @ org.springframework.test.conditionaltestcase.runbare(conditionaltestcase.java:79)     @ org.springframework.test.annotation.abstractannotationawaretransactionaltests.access$001(abstractannotationawaretransactionaltests.java:74)     @ org.springframework.test.annotation.abstractannotationawaretransactionaltests$1.run(abstractannotationawaretransactionaltests.java:179)     @ org.springframework.test.annotation.abstractannotationawaretransactionaltests.runtest(abstractannotationawaretransactionaltests.java:287)     @ org.springframework.test.annotation.abstractannotationawaretransactionaltests.runtesttimed(abstractannotationawaretransactionaltests.java:258)     @ org.springframework.test.annotation.abstractannotationawaretransactionaltests.runbare(abstractannotationawaretransactionaltests.java:176)     @ junit.framework.testresult$1.protect(testresult.java:110)     @ junit.framework.testresult.runprotected(testresult.java:128)     @ junit.framework.testresult.run(testresult.java:113)     @ junit.framework.testcase.run(testcase.java:124)     @ junit.framework.testsuite.runtest(testsuite.java:232)     @ junit.framework.testsuite.run(testsuite.java:227)     @ org.junit.internal.runners.junit38classrunner.run(junit38classrunner.java:79)     @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:86)     @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:459)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:678)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:382)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:192) caused by: org.springframework.beans.factory.beancreationexception: not autowire field: private java.lang.string com.devices.services.impl.criteriaserviceimpl.emailnotificationperiodindays; nested exception org.springframework.beans.factory.beanexpressionexception: expression parsing failed; nested exception org.springframework.expression.spel.spelevaluationexception: el1008e:(pos 0): field or property 'applicationproperties' cannot found on object of type 'org.springframework.beans.factory.config.beanexpressioncontext'     @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:517)     @ org.springframework.beans.factory.annotation.injectionmetadata.inject(injectionmetadata.java:87)     @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:286)     ... 35 more caused by: org.springframework.beans.factory.beanexpressionexception: expression parsing failed; nested exception org.springframework.expression.spel.spelevaluationexception: el1008e:(pos 0): field or property 'applicationproperties' cannot found on object of type 'org.springframework.beans.factory.config.beanexpressioncontext'     @ org.springframework.context.expression.standardbeanexpressionresolver.evaluate(standardbeanexpressionresolver.java:142)     @ org.springframework.beans.factory.support.abstractbeanfactory.evaluatebeandefinitionstring(abstractbeanfactory.java:1318)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.doresolvedependency(defaultlistablebeanfactory.java:782)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.resolvedependency(defaultlistablebeanfactory.java:770)     @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:489)     ... 37 more caused by: org.springframework.expression.spel.spelevaluationexception: el1008e:(pos 0): field or property 'applicationproperties' cannot found on object of type 'org.springframework.beans.factory.config.beanexpressioncontext'     @ org.springframework.expression.spel.ast.propertyorfieldreference.readproperty(propertyorfieldreference.java:216)     @ org.springframework.expression.spel.ast.propertyorfieldreference.getvalueinternal(propertyorfieldreference.java:85)     @ org.springframework.expression.spel.ast.propertyorfieldreference.getvalueinternal(propertyorfieldreference.java:78)     @ org.springframework.expression.spel.ast.compoundexpression.getvalueref(compoundexpression.java:49)     @ org.springframework.expression.spel.ast.compoundexpression.getvalueinternal(compoundexpression.java:82)     @ org.springframework.expression.spel.ast.spelnodeimpl.getvalue(spelnodeimpl.java:93)     @ org.springframework.expression.spel.standard.spelexpression.getvalue(spelexpression.java:89)     @ org.springframework.context.expression.standardbeanexpressionresolver.evaluate(standardbeanexpressionresolver.java:139)     ... 41 more 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -