Spring AOP : error at :零 can't find referenced pointcut actionMethod
Spring AOP : error at ::0 can't find referenced pointcut actionMethod
在使用spring3.1 AOP 切面编程的时候出现了以上错误和以下错误
java.lang.IllegalArgumentException: ProceedingJoinPoint is only supported fo
以下是在报错误时用的一种写法:
@Aspect
@Component
public class Interceptor {
@SuppressWarnings("unused")
@Pointcut("execution(java.lang.String com.shop.action..*.*())")
private void actionMethod(){}
@Around("actionMethod()")
public Object doInterceptor(ProceedingJoinPoint pjp) throws Throwable{
System.out.println("拦截到了:"+pjp.getSignature().getName()+"方法");
return pjp.proceed();
}
}
使用这种方法在以前的spring2中中好像是没有问题的,现在好像不行了,经过大量的google和度娘都说是jdk1.5和Jar包问题,可是我用的是jdk1.6嘛,所以排除了,经过了一翻总结:我使用了以下方法重写:
@Aspect
@Component
public class Interceptor {
//@SuppressWarnings("unused")
//@Pointcut("execution(java.lang.String com.shop.action..*.*())")
//private void actionMethod(){}
//@Around("actionMethod()")
@Around("execution(java.lang.String com.shop.action..*.*())")
public Object doInterceptor(ProceedingJoinPoint pjp) throws Throwable{
System.out.println("拦截到了:"+pjp.getSignature().getName()+"方法");
return pjp.proceed();
}
}
以上问题得到解决,成功实现方法拦截,原因还得去瞧spring3.1源码。