0
パッケージ内のすべてのBeanをスキャンしてメソッドをインターセプトすることで、バンプaopの動的ポイントカットを使用してログを記録する方法はありますか?spring-aopロギングの動的ポイントカット?
パッケージ内のすべてのBeanをスキャンしてメソッドをインターセプトすることで、バンプaopの動的ポイントカットを使用してログを記録する方法はありますか?spring-aopロギングの動的ポイントカット?
以下は、特定のパッケージ内のすべてのクラスのすべてのパブリックメソッドをインターセプトするアスペクトの例です。それを出発点として使用することができます。
@Aspect
public class LoggingAspect{
@Around("execution(public com.test.model..*.*(..))")
public void logInvocation(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("Doing some logging before");
joinPoint.proceed(); // execute the target method
System.out.println("Doing some logging after");
}
}
クラス内のすべてのメソッドをインターセプトする方法はわかりません。私は特定のメソッドマッチをインターセプトしようとしました。 – Mahesh
[すべてのメソッドを取得するためにリフレクションを使用](https://stackoverflow.com/questions/5266532/can-i-get-all-methods-of-a-class)、そこから作業を進めてください。 – Makoto