本來我是使用@annotation() 直接切面指定註解的,結果方法內部調用的方法無法切入,因此我使用了一下方式替代。切面Action下所有類所有方法,同時方法上有ExecuteTask註解的才進行切面
@Component
@Aspect
public class AopTest {
@Before(value = "execution(* com.epoch.planning.action.*.*(..)) && @target(com.epoch.planning.utils.task.ExecuteTask)")
public void before(JoinPoint pjp){
MethodSignature signature = (MethodSignature) pjp.getSignature();
ExecuteTask annotation = signature.getMethod().getAnnotation(ExecuteTask.class);
}
}