在 com.repository 包中我有:擴(kuò)展 spring data Repository 的獨(dú)立接口在同一個(gè)包中使用我自己的實(shí)現(xiàn)擴(kuò)展 spring data Repository 的接口實(shí)現(xiàn)我的存儲(chǔ)庫接口的存儲(chǔ)庫類我想測量 com.repository 包中所有方法的執(zhí)行時(shí)間(與數(shù)據(jù)庫的通信)。但我想避免重復(fù)現(xiàn)在與@Pointcut("執(zhí)行(public * com.repository. . (..))")我有一些方法記錄了兩次 - 來自接口和實(shí)現(xiàn)該接口的類。我不想記錄在同一包中實(shí)現(xiàn)類的接口中的方法,或者不記錄在同一包中實(shí)現(xiàn)接口的類中的方法。我該如何用切入點(diǎn)和建議來表達(dá)它?我的問題與 AspectJ 有點(diǎn)相關(guān):在 @Around 建議中組合多個(gè)切入點(diǎn)時(shí)出現(xiàn)問題,但它并不能解決我的問題。
1 回答

達(dá)令說
TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超6個(gè)贊
如果您正在監(jiān)視的對象位于特定包,為什么您不將切入點(diǎn)僅綁定到該包。
所以使用
@Pointcut("execution(* com.repository.*.*(..))")
代替
@Pointcut("execution(public * com.repository..*.*(..))")
其中包括“com.repository”包及其所有子包。
添加回答
舉報(bào)
0/150
提交
取消