我試圖建立Spring AOP框架,我不希望依賴於AspectJ的,所以我在類似下面的一個bean的XML配置文件中聲明我的問題,建議等:爲什麼如果spring不依賴aspectj,會拋出一個aspectj錯誤?
<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。然而,這不應該是這種情況。有什麼想法嗎?
在此先感謝
而下一個代碼塊是普通的舊香草Spring AoP: - >這是不正確的。它只是一個指向系統級切入點類的鏈接:https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#aop-common-pointcuts –