记一次使用AOP获取参数的坑

532 阅读1分钟

背景

使用AOP获取被调用方法的入参,然后用@Around触发业务方法,将获取到的参数传递下去,如: 想要获取AutoServiceImpl.excute(),中的Role

使用@Pointcut切入到指定的方法上

使用@Around通知被调用的业务方法,通过ProceedingJoinPoint获取获取到的参数

开始在@Around中没有加args(object),导致报

error at ::0 formal unbound in pointcut

网上翻阅资料得到当被切入的方法有参数时,@Around所在的方法需要有一个形式参数,并使用 args()接收