0
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyDemoLogginAspect {

    @Before("execution(* * add*())")
    public void beforeAddAccountAdvice(){

        System.out.println("Executing before");

    }
}

I am getting an exception of Caused by:

 java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting '(' at character position 14
execution(* * add*()) 

I need to know why the above pointcut expression is wrong?

Note: This error is coming after execution of the main class but there is nothing wrong with the main class and the error is instead within the pointcut expression

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373

1 Answers1

2

Incorrect pointcut expression.

From the documentation .

The format of an execution expression is:

execution(modifiers-pattern? ret-type-pattern 
declaring-type-pattern?name-pattern(param-pattern)throws-pattern?)

The correct format for your example to work is

@Before("execution(* add*())")

The modifiers-pattern is optional and cannot be a wildcard (*) and should be one of public or protected . Details here

So the pointcut expression may also be

@Before("execution(public * add*())")

Also note that your pointcut expression is too global and can result in undesired result as kriegaex points out in this answer to another SO question

R.G
  • 6,436
  • 3
  • 19
  • 28