Bird
0
0

In a Spring Boot application, where should the @EnableCaching annotation be placed to activate caching support?

easy📝 Syntax Q3 of 15
Spring Boot - Caching
In a Spring Boot application, where should the @EnableCaching annotation be placed to activate caching support?
AOn the main application class only
BDirectly on the service method that needs caching
COn a configuration class annotated with <code>@Configuration</code>
DOn the repository interface
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of @EnableCaching

    This annotation enables Spring's annotation-driven cache management capability.
  2. Step 2: Placement of @EnableCaching

    It must be placed on a configuration class (usually annotated with @Configuration) so that Spring can process it during context initialization.
  3. Final Answer:

    On a configuration class annotated with @Configuration -> Option C
  4. Quick Check:

    Annotation activates caching at configuration level [OK]
Quick Trick: Place @EnableCaching on a @Configuration class [OK]
Common Mistakes:
  • Placing @EnableCaching on service methods
  • Assuming @EnableCaching works without @Configuration
  • Putting @EnableCaching on repository interfaces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes