Spring Boot Annotations Overview — Spring Technical Interview Questions & Answers

@SpringBootApplication, @RestController, @Autowired and more.

Spring Boot Annotations Overview

  • Annotations tell Spring what each class/method is for.
  • @SpringBootApplication: Marks the main class; turns on config, auto-config, and component scan.
  • @RestController / @Controller: Handles web requests.
  • @Service / @Repository / @Component: Registers classes as Spring beans with clear roles.
  • @Autowired: Asks Spring to inject a needed dependency (prefer constructor injection).
  • @GetMapping / @PostMapping: Map HTTP routes to methods.
  • @Value: Reads a value from application.properties.
  • Memorising 30 annotations but not explaining the top 6.
  • Explain @SpringBootApplication as three annotations in one.

Technical Interview Tip: @SpringBootApplication = @Configuration + @EnableAutoConfiguration + @ComponentScan.

Code Examples for Spring Boot Annotations Overview

Spring Boot Annotations Overview — working example

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication // config + auto-config + component scan
public class DemoApplication {
  public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
  }
}

@RestController
class HelloController {
  @GetMapping("/api/hello")
  String hello() {
    return "Hello Spring Boot";
  }
}

Spring Boot Annotations Overview — spring Boot is opinionated Spring: starters + auto-configuration + embedded server for fast apps.

How to Explain Spring Boot Annotations Overview to an Interviewer

What is Boot Annotations Overview (sb)?

Used for a short Boot Annotations Overview sb example a small REST app Not just the heading

Give one small example of Boot Annotations Overview (sb).

the smallest Boot Annotations Overview sb example you can type @SpringBootApplication, @RestController, @Autowired and more

What mistake do beginners make with Boot Annotations Overview (sb)?

only saying “Boot Annotations Overview sb” with no example Show the fix

Where do you use Boot Annotations Overview (sb)?

a small REST app a short Boot Annotations Overview sb example