I am trying to call the before advice , but the same is not getting executed with the defined pointcut
i have main applicaiton in the package com.my.ms
@SpringBootApplication
@EnableAspectJAutoProxy
public class TemplateServiceApplication {
public static void main(String[] args) {
SpringApplication.run(TemplateServiceApplication.class, args);
}
}
and in package com.my.ms.tst.advices i have the before advice
@Aspect
public class ValidatingAdvices {
@Before(value = "execution(* com.my.ms.tst.api.*.get*(..))")
public void validateKey(JoinPoint joinPoint) throws Throwable {
System.out.println("Executing the before advice");
}
}
the controller lies in the package com.my.ms.tst.api
@Controller
@RequestMapping("/ts")
public class MainController {
@GetMapping("/check")
public String getTemp() throws IOException {
return "five";
}
}
But the Below Advice is not getting executed
You add @Configuration annotation in ValidatingAdvices.
@Configuration
@Aspect
public class ValidatingAdvices {
@Before(value = "execution(* com.my.ms.tst.api.*.get*(..))")
public void validateKey(JoinPoint joinPoint) throws Throwable {
System.out.println("Executing the before advice");
}
}