gpt4 book ai didi

java - @AspectJ 包的执行方法的切入点

转载 作者:行者123 更新时间:2023-11-30 05:55:50 25 4
gpt4 key购买 nike

我想执行特定包中的执行方法。

这可能是什么切入点?

注意:我正在使用@AspectJ 风格的Spring AOP。

最佳答案

看这里http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html

@(org.xyz..*) Matches any annotated element which has either an annotation of a type matching the type pattern (org.xyz..*). In other words, an annotated element with an annotation that is declared in the org.xyz package or a sub-package. (The parenthesis are required in this example).

所以你应该有以下 aop 配置:

<aop:config>
<aop:advisor advice-ref="myAdvice" pointcut="execution(* com.mycompany..*(..))" order="1"/>
</aop:config>

和这个建议的匹配bean

<bean id="myadvice" class="com.mycompany.MyIntercetpor"/>

拦截器应该实现 org.aopalliance.intercept.MethodInterceptor

关于java - @AspectJ 包的执行方法的切入点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7802980/

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