2017-04-04 21 views

回答

0

使用Spring AOP圍繞此建議可以實現。

寫一個切入點,這將攔截

在包公共方法(一個或多個)的所有執行&它的子包 且屬於包&它的子包 控制器層 服務層(任選地限制到一個特定的服務專用) DAO層 然後寫的環繞通知如下

@Component 
@Aspect 
public class TraceAdvice { 

    @Around("execution(* com.test..*(..)) &&" + " (within(com.test.controller..*) || " 
     + "(within(com.test.service..*) && this(com.test.service.TestService)) || " + "within(com.test.dao..*))") 
    public Object traceCall(ProceedingJoinPoint pjp) throws Throwable { 
... your logic 
} 
+0

我是初學者與Spring框架。無法理解這一點 –

相關問題