<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>
上記のコードでは、春の表現言語を使用してBeansong
のinstrument
プロパティを注入しています。eddie
しかし、song
プロパティが適切に挿入されていません。次のエラーが発生します。
スレッド「main」の例外org.springframework.beans.factory.BeanCreationException:クラスパスリソース[spring-config.xml]で定義された「eddie」という名前のBeanの作成中にエラーが発生しました:Beanの初期化に失敗しました。ネストされた例外はorg.springframework.beans.factory.BeanExpressionExceptionです:式の解析に失敗しました。ネストされた例外はorg.springframework.expression.spel.SpelEvaluationExceptionです:EL1008E:(pos 6):フィールドまたはプロパティ「song」がorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactoryのタイプ「$Proxy4」のオブジェクトで見つかりません。 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)のdoCreateBean(AbstractAutowireCapableBeanFactory.java:519)org.springframework.beans。
楽器のプロパティは適切に挿入されますが、曲のプロパティは挿入されません。これはaopのみが原因で発生します。
コメントアウトすると、正常に機能し<aop:config>
ています。
何か問題がありますか?