<bean id="eddie" class="com.springinaction.Instrumentalist"> <property name="instrument" value="#{violin}"></property> <property name="song" value="#{kenny.song}"></property> </bean> <bean id="violin" class="com.springinaction.Violin"> </bean> <bean id="kenny" class="com.springinaction.Instrumentalist"> <property name="song" value="Kenny is a star,kenny is a star"></property> <property name="instrument" ref="saxopone"></property> </bean> <aop:config> <aop:aspect ref="audience"> <aop:before pointcut="execution(* com.springinaction.Performer.perform(..))" method="takeSeats()"/> <aop:after-throwing method="demandRefund" pointcut="execution(* com.springinaction.Performer.perform(..))"/> </aop:aspect> </aop:config>
In the above code, I insert the song , instrument property of the eddie bean using the spring expression language. But the song property is not being entered correctly .. and I get the following error:
An exception in the stream "main" org.springframework.beans.factory.BeanCreationException: Error creating bean named 'eddie' defined in class path resource [spring -config.xml]: Bean initialization failed; nested exception org.springframework.beans.factory.BeanExpressionException: Failed to parse expressions; nested exception org.springframework.expression.spel.SpelEvaluationException: EL1008E: (item 6): field or property "Song" cannot be found on the object, enter '$ Proxy4' in org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory. doCreateBean (AbstractAutowireCapableBeanFactory.javaPoint19) in org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:450 ) in org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222) in org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java.org factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:189) in org.springfr amework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java► 5757) in org.springframework.context.support.AbstractApplicationContext.finishBeanFrejectFretextFretext.worktextontext AbstractApplicationContext.java:416) in org.springframework.context.support.ClassPas thanksmlApplicationContext. (ClassPas thanksmlApplicationContext.java: 139) in org.springframework.context.support.ClassPas thanksmlApplicationContext. (ClassPas thanksmlApplicationContext.java: 83) in com.springinaction.Main.main (Main.java:10)
The instrument property is entered correctly when the song property is not entered, and this is due only to aop.
when I comment on <aop:config> , it works fine.
Something is wrong?
source share