@Aspect
@Component
public class ionImpAop { @Pointcut("@annotation(net.spring.intf.iocImp)")
public void ionImpMethod() {
} @Before("ionImpMethod()")
public void beforeMethod() {
System.out.println("before");
} @Around("ionImpMethod()")
public Object aroundMethod(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
Object object = null;
try {
object = proceedingJoinPoint.proceed();
} catch (Exception e) {
throw e;
}
System.out.println("around");
return object;
} @After("ionImpMethod()")
public void afterMethod() {
System.out.println("after");
}
}为什么  @Around 下面那个方法加上  throws Throwable @Before 跟原来调用service后面的方法能够执行
没加上  throws Throwable   这个的时候,只能进入到 @After 方法 ,@Before 方法不进,而且调用 service方法的后续代码也不执行

解决方案 »

  1.   

    @Around("ionImpMethod()")
    public Object aroundMethod(ProceedingJoinPoint joinPoint) throws Throwable {
    Object object = null;
    try {
    object = joinPoint.proceed();
    } catch (Exception e) {
    throw e;
    }
    // net.spring.service.helloService@684c4676
    Object tar = joinPoint.getTarget(); Object[] meth= joinPoint.getArgs(); // List net.spring.service.helloService.getList()
    Signature signature = joinPoint.getSignature(); Object htis = joinPoint.getThis(); System.out.println("around");
    return object;
    }
    我改成这样 Object[] meth= joinPoint.getArgs();   为甚 meth 一直是空的,并没有前面调用的