Bird
0
0

In Spring Boot, which annotation must be used to declare a class as an aspect for AOP?

easy📝 Syntax Q3 of 15
Spring Boot - Aspect-Oriented Programming
In Spring Boot, which annotation must be used to declare a class as an aspect for AOP?
A@Aspect
B@ComponentScan
C@Service
D@Configuration
Step-by-Step Solution
Solution:
  1. Step 1: Identify aspect declaration

    Spring AOP requires the @Aspect annotation to mark a class as an aspect.
  2. Step 2: Differentiate from other annotations

    @ComponentScan is for scanning components, @Service marks service beans, and @Configuration is for config classes.
  3. Final Answer:

    @Aspect -> Option A
  4. Quick Check:

    Aspect classes use @Aspect annotation [OK]
Quick Trick: Use @Aspect to define an aspect class [OK]
Common Mistakes:
  • Using @ComponentScan instead of @Aspect
  • Confusing @Service with aspect declaration
  • Assuming @Configuration marks aspects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes