Bird
0
0

Which annotation is used to mark the main class in a Spring Boot application?

easy📝 Syntax Q12 of 15
Spring Boot - Fundamentals
Which annotation is used to mark the main class in a Spring Boot application?
A@Controller
B@Service
C@Entity
D@SpringBootApplication
Step-by-Step Solution
Solution:
  1. Step 1: Identify main class annotation

    The main class in Spring Boot is marked with @SpringBootApplication to enable auto-configuration and component scanning.
  2. Step 2: Review other annotations

    @Controller is for web controllers, @Entity for database entities, and @Service for service layer components, not for main app class.
  3. Final Answer:

    @SpringBootApplication -> Option D
  4. Quick Check:

    Main class annotation = @SpringBootApplication [OK]
Quick Trick: Main class uses @SpringBootApplication annotation [OK]
Common Mistakes:
  • Confusing @Controller with main class annotation
  • Using @Entity or @Service incorrectly for main class
  • Missing the auto-configuration role of @SpringBootApplication

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes