bet*_*rad 2 aop spring aspectj spring-aop
我正在尝试设置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>
Run Code Online (Sandbox Code Playgroud)
每当我指定切入点时,我都会收到以下错误:
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**
Run Code Online (Sandbox Code Playgroud)
当我包含aspectjweaver.jar时,我可以使这个工作.但事实并非如此.有什么想法吗?
提前致谢
请参阅Spring docs 启用@AspectJ支持:
可以使用XML或Java样式配置启用@AspectJ支持.在任何一种情况下,您还需要确保AspectJ的aspectjweaver.jar库位于应用程序的类路径中(版本1.6.8或更高版本).
当然,如果要使用aspectj提供的功能,则需要一些aspectj库.但是我想在运行时将它放在类路径上已经足够了,所以你的项目不一定会对这个jar有一个编译时依赖.
| 归档时间: |
|
| 查看次数: |
5840 次 |
| 最近记录: |