Categories: java, spring, aop

Second annotated aspect not being called

1 answer

I'm trying to get my head around Spring AOP and currently are facing the issue, that the second aspect annotated by TrackedSubTask is not being called, while the Tracked works. Any help or clue is appreciated.

Here are my annotated classes:

@RestController public class Demo {     @Tracked     @RequestMapping("/")     public String index() {         DemoImpl bar = new DemoImpl();;         return "Greetings from Spring Boot!";     } }  public class DemoImpl{     @TrackedSubTask     public void foo() {         System.out.println("foo");     } } 

Here are my annotations:

@Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Tracked  { }  @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface TrackedSubTask { } 

Here are my aspects:

@Aspect @Component class MyAspect {     @Around("@annotation(annotation)")     public Object first(ProceedingJoinPoint joinPoint, Tracked annotation) throws Throwable {         Object proceed = joinPoint.proceed();         return proceed;     }      @Around("@annotation(subTaskAnnotation)")     public Object second(ProceedingJoinPoint joinPoint, TrackedSubTask subTaskAnnotation) throws Throwable {         Object  proceed = joinPoint.proceed();         return proceed;     } } 

All answers to this question, which has the identifier 61224374

The best answer:

As M. Deinum correctly pointed out, the DemoImpl needed to be managed by Spring.

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type is referenced as an interface from”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data