Bird
0
0

You wrote a Spring Boot app but it fails to start due to missing @SpringBootApplication annotation. What is the fix?

medium📝 Debug Q6 of 15
Spring Boot - Fundamentals
You wrote a Spring Boot app but it fails to start due to missing @SpringBootApplication annotation. What is the fix?
AAdd @SpringBootApplication on the main class to enable auto-configuration
BAdd XML config files to the resources folder
CRemove the main method and use a servlet container
DManually instantiate all beans in main method
Step-by-Step Solution
Solution:
  1. Step 1: Identify missing annotation role

    @SpringBootApplication enables component scanning and auto-configuration needed for app startup.
  2. Step 2: Apply correct fix

    Adding this annotation on the main class resolves startup failure by enabling Spring Boot features.
  3. Final Answer:

    Add @SpringBootApplication on the main class to enable auto-configuration -> Option A
  4. Quick Check:

    Missing annotation fix = D [OK]
Quick Trick: Always annotate main class with @SpringBootApplication [OK]
Common Mistakes:
  • Adding unnecessary XML config
  • Removing main method incorrectly
  • Trying to manually create beans in main

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes