Bird
0
0

Which annotation is used in Spring Boot to define an aspect for cross-cutting concerns?

easy📝 Syntax Q12 of 15
Spring Boot - Aspect-Oriented Programming
Which annotation is used in Spring Boot to define an aspect for cross-cutting concerns?
A@Aspect
B@Controller
C@Service
D@Repository
Step-by-Step Solution
Solution:
  1. Step 1: Recall Spring AOP annotations

    Spring Boot uses Aspect-Oriented Programming (AOP) to implement cross-cutting concerns, and the key annotation to define an aspect is @Aspect.
  2. Step 2: Differentiate from other annotations

    @Controller is for web controllers, @Service for service layer, and @Repository for data access. None of these define aspects.
  3. Final Answer:

    @Aspect -> Option A
  4. Quick Check:

    Aspect annotation = @Aspect [OK]
Quick Trick: Use @Aspect to mark cross-cutting concern classes [OK]
Common Mistakes:
  • Choosing @Controller or @Service by mistake
  • Confusing @Aspect with @Component
  • Not knowing which annotation defines an aspect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes