这是方面类
public class TransactionAspect {
public void beforeAnything() throws IOException{
System.out.println("In the aspect");
}
public void beforeWithdrawalTransaction() throws IOException{
System.out.println("In the aspect");
}
public void beforeDepositTransaction() throws IOException{
System.out.println("In the aspect");
}
public void beforeBalance() throws IOException{
System.out.println("In the aspect");
}
}
这是我的方面的xml配置文件我尝试了不同的方法,但仍然无法正常工作
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<aop:config>
<aop:pointcut id="forAnything" expression="execution(* com.pack.service.*.*(..))" />
<aop:advisor advice-ref="myAspectBean" pointcut="forAnything" id="interceptor" ></aop:advisor>
<aop:aspect id="myAspect" ref="myAspectBean">
<aop:before method="beforeWithdrawalTransaction" />
<aop:before method="beforeDepositTransaction" />
<aop:before method="beforeBalance"/>
</aop:aspect>
</aop:config>
<bean id="myAspectBean" class="com.pack.aspect.TransactionAspect"/>
</beans>
当我尝试加载我的应用程序时,出现此错误:
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Must define one of 'pointcut' or 'pointcut-ref' on <advisor> tag.
Offending resource: class path resource [Spring.xml]
Aspect: id='myAspect'
-> Advice (before)
答案 0 :(得分:0)
我建议你将属性,pointcut-ref =&#34; pointcut_id&#34;添加到标签