gpt4 book ai didi

java - 必须在 上定义 'pointcut' 或 'pointcut-ref' 之一

转载 作者:太空宇宙 更新时间:2023-11-04 11:25:57 25 4
gpt4 key购买 nike

这是方面类

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)

最佳答案

我建议您将属性 pointcut-ref ="pointcut_id"添加到标签

关于java - 必须在 <advisor> 上定义 'pointcut' 或 'pointcut-ref' 之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44368707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com