Hackforge Academy

Category: java

spring boot interview questions

Published on 15 Apr 2026

Explanation

What is Spring Boot and why is it used?

Code:

Spring Boot is a framework built on top 
of Spring that simplifies application
 development by providing 
auto-configuration, embedded servers,
 and production-ready features.

Example:
@SpringBootApplication
public class DemoApplication {
  public static void main(String[] args) {
    SpringApplication.run(DemoApplication.
class, args);
  }
}

Explanation

What is @SpringBootApplication annotation?

Code:

@SpringBootApplication is a combination of:
1. @Configuration
2. @EnableAutoConfiguration
3. @ComponentScan

It enables auto configuration and 
component scanning.

Explanation

What is auto-configuration in Spring Boot?

Code:

Auto-configuration automatically 
configures beans based on 
dependencies available in the classpath.

Example:
If spring-boot-starter-web is added, 
DispatcherServlet is configured 
automatically.

Explanation

What are Spring Boot Starters?

Code:

Starter dependencies simplify 
dependency management.

Example:
<dependency>
  <groupId>org.springframework.boot
</groupId>
  <artifactId>spring-boot-starter-web
</artifactId>
</dependency>

Explanation

What is the difference between @Component, @Service, @Repository, and @Controller?

Code:

@Component β†’ Generic bean
@Service β†’ Business logic layer
@Repository β†’ Persistence layer
@Controller β†’ Web MVC controller

Explanation

What is @RestController?

Code:

@RestController combines 
@Controller and @ResponseBody.

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

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community