2021年4月11日星期日

Spring AOP @Pointcut and @Before yields IllegalArgumentException: error at ::0 formal unbound in pointcut

I am doing a springboot project that includes login and accounts. I am trying to @Pointcut all controller method calls and validate the login information, and @Before the pointcut to make sure the session exists. Hence the code:

@Aspect  @Component  public class AuthAspect {      Logger logger = LoggerFactory.getLogger(AuthAspect.class);        @Pointcut("execution(* show.xianwu.game.frisbeescorer.controller.*.*(..))")      public void validateLogin(JoinPoint joinPoint) {          // check the login information      }        @Before("validateLogin()")      public void validateSession(JoinPoint joinPoint) {          // check the session      }  }  

However, this yields org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectingArgumentResolverBeanPostProcessor' defined in class path resource [org/springframework/data/web/config/ProjectingArgumentResolverRegistrar.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut.

Deleting the validateSession() and @Before makes the @Pointcut work. How can I fix this?

https://stackoverflow.com/questions/67051840/spring-aop-pointcut-and-before-yields-illegalargumentexception-error-at-0-f April 12, 2021 at 10:07AM

没有评论:

发表评论