Spring Aop切面註解 解決@annotation()無法切入方法內部調用的問題

本來我是使用@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);
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章