我正在尝试设置 Spring AoP 框架并且我不想依赖 AspectJ,所以我在 bean xml 配置文件中声明了我的方面、建议等,类似于以下内容:
<bean id="systemAuthorizationsAspect" class="com.cp.pm.systemsettings.SystemAuthorizationsAspect" >
<property name="sysAuthorizations" ref="authorizations" />
</bean>
<bean id="authorizations" class="com.hp.cp.pm.systemsettings.SystemAuthorizationsImpl">
<property name="authSettingsRegistry" ref="systemSettingsRegistry" />
</bean>
<aop:config>
<aop:aspect id="createPlanAspect" ref="systemAuthorizationsAspect">
<aop:before pointcut="execution(* com.hp.cp.web.api.plan.PlanApi.createPlan(..))" method="authorizePlanCreation"/>
</aop:aspect>
</aop:config>
每当我指定如上所示的切入点时,我都会收到以下错误:
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 create inner bean '(inner bean)' of type [org.springframework.aop.aspectj.AspectJExpressionPointcut] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)':
Instantiation of bean failed; nested exception is **java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException**
当我包含 aspectjweaver.jar 时,我可以完成这项工作。然而,这不应该是这样的。有什么想法吗?
提前致谢