when annotating an advice method with the pointcut, spring throws an error

error Type referred to is not an annotation type: LogCommands

Turns out spring is picking up the annotation name and using it for reflection and then load the interface for AOP stuff.

So the solution is to mark the type as complete full interface name, (unless its within same package)

for example, instead of

@Before("@annotation(LogCommands)")

public void logCommands(JoinPoint joinPoint) throws Throwable {

String command = joinPoint.getSignature().getName();

String input = Arrays.stream(joinPoint.getArgs()).toString();

.....

}

a FQN make it work

@Before("@annotation(com.abc.svc.annotation.LogCommands)")
public void logCommands(JoinPoint joinPoint) throws Throwable {
String command = joinPoint.getSignature().getName();
String input = Arrays.stream(joinPoint.getArgs()).toString();
.....
}

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store