Spring Boot Interview Questions

  • Spring Framework: Requires extensive XML or Java configuration, manual server setups, and explicit version tracking for each dependency.
  • Spring Boot: Built on top of Spring to provide “convention over configuration”. It features auto-configuration, embedded servers, and starter POMs to get applications running instantly.
  • Spring Boot Starters: Aggregated dependency descriptors that simplify build configurations.
  • Auto-Configuration: Dynamically provisions beans on the classpath.
  • Embedded Servers: Tomcat, Jetty, or Undertow built directly into the deployable JAR.
  • Spring Boot Actuator: Provides operational endpoints like /health and /metrics for production monitoring.
It is a convenience annotation that wraps three core configurations:
  • @Configuration: Marks the class as a source of bean definitions.
  • @EnableAutoConfiguration: Instructs Spring Boot to scan dependencies and auto-configure matching components.
  • @ComponentScan: Directs Spring to scan the package and its sub-packages for stereotypes (@Component, @Service, @Repository, @Controller).

Starters are pre-packaged dependency templates. Adding a single starter like spring-boot-starter-web automatically pulls in Spring MVC, Tomcat, and Jackson JSON parsers. The versions are internally managed by the spring-boot-dependencies parent POM, preventing library version conflicts.

  • @Controller: Used for legacy MVC web applications. Methods return a String path mapping to a target view (like Thymeleaf, JSP, or HTML).
  • @RestController: Designed for REST APIs. It combines @Controller and @ResponseBody, ensuring method return values are automatically serialized into JSON or XML response bodies.
  • @Component: A generic stereotype annotation indicating the class is a managed Spring bean.
  • @Bean: Used explicitly inside @Configuration classes on methods to instantiate third-party or custom classes manually.
  • @Service: Specializes @Component to denote business logic layers.
  • @Repository: Specializes @Component for data access layers, enabling automatic translation of low-level SQL exceptions into Spring’s unified DataAccessException hierarchy.
  • @PathVariable: Extracts dynamic variables directly from the URI path structure (e.g., /users/{id}).
  • @RequestParam: Captures standard HTTP query parameters appended to the URL (e.g., /users?page=2).

We Provide the Best Service in Industry​

Add a line that tells users how easily they can get in touch with you
Scroll to Top