[英]Spring AOP logger, pointcut definition
I'm trying to introduce a logger in my project using Spring AOP, but I'm new to AOP and to AspectJ syntax, so I'm having some troubles... 我正在尝试使用Spring AOP在我的项目中引入一个记录器,但我是AOP和AspectJ语法的新手,所以我遇到了一些麻烦......
I've defined a basic aspect-class following some tutorial/docs: 我已经在一些教程/文档之后定义了一个基本的方面类:
@Aspect
public class Logger {
@Pointcut("execution(* exportdatamanager.export.ExportType.fetch(..))")
public void fetch() {
}
// ...
@AfterReturning("fetch()")
public void fetchingResult(JoinPoint joinPoint, Object result) {
System.out.println("TEST LOG " + result.toString());
}
}
But when I run my application I get this exception: 但是当我运行我的应用程序时,我得到了这个异常
java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
What I'm doing wrong, I suppose there's something wrong in my ApsectJ expression... 我做错了什么,我想我的ApsectJ表达中出了点问题......
Can you also suggest me some quick reference to AspectJ syntax supported by Spring AOP? 您能否建议我快速参考 Spring AOP支持的AspectJ语法 ?
NOTE 注意
A snippet from my ExportType
interface 我的
ExportType
接口的片段
public interface ExportType {
List<Object> fetch() throws FetchingStrategyException;
// ...
}
Ok, I just solved my issue this way: 好的,我这样解决了我的问题:
@AfterReturning(pointcut = "fetch()", returning = "results")
public void fetchingResult(JoinPoint joinPoint, List<Object> results) {
System.out.println("TEST LOG " + results.toString());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.