AOP中需要引入aspectj包

 

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'knight' defined in class path resource [kinghtAopl.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.aspectj.AspectJMethodBeforeAdvice] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'embark' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embark': Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

<bean id="knight" class="com.wang.Frist.BraveKnight">
<constructor-arg ref="quest"/>
</bean>

<bean id="quest" class="com.wang.Frist.slayDragonquest">
<constructor-arg value="#{T(System).out}" />
</bean>

<bean id="minstrel" class="com.wang.Frist.Minstrel">
<constructor-arg value="#{T(System).out}" />
</bean>

<aop:config>
<aop:aspect ref="minstrel">
<aop:pointcut expression="execution(* *.embarkOnQuest(..))" id="embark"/>

<aop:before pointcut-ref="embark" method="singBeforeQuest"/>
<aop:after pointcut-ref="embark" method="singAfterQuest"/>
</aop:aspect>
</aop:config>

 

解决办法:

缺少jar包。自己一个一个的导入了一下就好了。

<dependency> 
<groupId> org.aspectj</groupId > 
<artifactId> aspectjweaver</artifactId > 
<version> 1.8.7</version > 
</dependency> 

posted @ 2017-03-08 16:28  mslog  阅读(8522)  评论(0编辑  收藏  举报