All questions
Showing of 72Explain the difference between Spring and Spring Boot.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Spring is the core framework that you configure yourself, while Spring Boot configures it for you. Spring Boot is built on top of Spring and adds opinionated defaults, so a new application runs with almost no setup.
| Aspect | Spring | Spring Boot |
|---|---|---|
| Configuration | Manual XML/Java configuration | Auto-configuration |
| Server Setup | External server required | Embedded server included |
| Dependencies | Manual dependency management | Starter dependencies |
| Deployment | WAR files to external servers | Executable JAR files |
| Development Time | More setup and configuration | Faster development |
Spring Boot does not replace Spring. Its auto-configuration creates the beans you would otherwise declare by hand, based on the libraries on the classpath. Starters add a tested set of libraries with one dependency. The embedded server lets you start the app with java -jar.
Your own configuration still takes precedence. When you declare a bean yourself, Spring Boot skips its default for that bean.
The deployment row is the usual case, not a limit. A Spring Boot app can still be packaged as a WAR for an external server, by extending SpringBootServletInitializer.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are Spring Boot Starters? Name some commonly used starters.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Spring Boot starters are dependency descriptors that bring in everything one feature needs through a single entry in your build file. Add spring-boot-starter-data-jpa, and you get Spring Data JPA and Hibernate at versions tested together.
Commonly used starters:
spring-boot-starter-webmvc: web apps and REST APIs with Spring MVC and Tomcat. Before Spring Boot 4 it wasspring-boot-starter-web, which still works but is deprecated.spring-boot-starter-data-jpa: JPA with Hibernatespring-boot-starter-security: Spring Securityspring-boot-starter-test: testing with JUnit and Mockitospring-boot-starter-actuator: monitoring and managementspring-boot-starter-data-redis: Redis data accessspring-boot-starter-mail: email support
You leave the versions off. Spring Boot's dependency management picks them, so upgrading Spring Boot upgrades the whole set.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the @SpringBootApplication annotation.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
@SpringBootApplication is a convenience annotation that combines three annotations. One line on the main class registers your configuration and turns on auto-configuration and component scanning.
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
It is equivalent to:
@SpringBootConfiguration: marks the class as a source of beans. It is a specialized@Configurationthat also helps tests find your configuration.@EnableAutoConfiguration: turns on auto-configuration, which creates beans from the libraries on the classpath.@ComponentScan: scans the current package and its sub-packages for components.
Scanning starts at the package of this class, so put the main class in a root package above your other classes.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between @Component, @Service, @Repository, and @Controller?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
All four mark a class as a Spring bean that component scanning picks up. They are stereotype annotations, and @Service, @Repository and @Controller are specializations of @Component that also name the layer the class belongs to.
@Componentis the generic stereotype for any Spring-managed class.@Servicemarks business logic in the service layer.@Repositorymarks data access. It also turns on exception translation, which converts database-specific exceptions into Spring'sDataAccessExceptionhierarchy.@Controllermarks the presentation layer. Spring MVC treats these classes as handlers for HTTP requests.
@Service
public class UserService { }
@Repository
public class UserRepository { }
@Controller
public class UserController { }
For component scanning, the four behave the same. The specific annotation still matters, because tools and aspects can target a layer by its annotation. Spring may also give these annotations more behavior in future versions, so use the one that matches the role of the class.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you create a RESTful web service in Spring Boot?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
You create a REST service by adding the web starter and writing a class annotated with @RestController. Each handler method maps an HTTP method and a path to Java code, and Spring converts the return value to JSON.
- Add the web starter,
spring-boot-starter-webmvc, namedspring-boot-starter-webbefore Spring Boot 4. It brings Spring MVC, the Jackson JSON library and an embedded Tomcat web server. - Annotate a class with
@RestControllerand give it a base path with@RequestMapping. - Map each operation with a shortcut annotation that has the HTTP method built in, such as
@GetMappingor@PostMapping. - Read input with
@PathVariablefor a path segment and@RequestBodyfor a JSON body.
@RestController
@RequestMapping("/api/users")
public class UserController {
@Autowired
private UserService userService;
@GetMapping
public List<User> getAllUsers() {
return userService.findAll();
}
@GetMapping("/{id}")
public User getUser(@PathVariable Long id) {
return userService.findById(id);
}
@PostMapping
public User createUser(@RequestBody User user) {
return userService.save(user);
}
// ...
}
Start the @SpringBootApplication main class, and a GET request to /api/users/1 returns that user as JSON. To choose the status code yourself, return a ResponseEntity, for example 201 Created from the POST method.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between @RequestMapping and @GetMapping?
Explain Spring Boot's embedded server concept.
What are the different ways to run Spring Boot applications?
What is the difference between @RestController and @Controller?
What are Spring Boot DevTools and how do they improve development?
Explain Inversion of Control (IoC) and Dependency Injection (DI).
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Inversion of Control (IoC) is the principle that a container, not your code, creates objects and manages them. In Spring that container is usually an ApplicationContext. Dependency Injection (DI) is how Spring puts IoC into practice. An object declares what it needs, and the container passes those dependencies in.
// Without DI - tight coupling
public class UserService {
private UserRepository userRepository = new UserRepository(); // Tight coupling
}
// With DI - loose coupling
public class UserService {
private UserRepository userRepository;
public UserService(UserRepository userRepository) {
this.userRepository = userRepository; // Dependency injected
}
}
In the first class, UserService builds its own UserRepository with new, so the two are tightly coupled. You cannot swap in another implementation or a test mock without editing the class.
In the second class, the dependency arrives through the constructor. Spring chooses what to inject, and a unit test can pass a mock. That is loose coupling.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are the different types of Dependency Injection in Spring?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Spring supports three types of dependency injection: constructor, setter and field injection.
- Constructor injection passes dependencies as constructor arguments.
- Setter injection calls a setter marked with
@Autowiredafter the object is created. - Field injection puts
@Autowiredon a field, and Spring sets it through reflection.
// Constructor Injection (Recommended)
@Service
public class UserService {
private final UserRepository userRepository;
public UserService(UserRepository userRepository) {
this.userRepository = userRepository;
}
}
// Field Injection
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
}
Prefer constructor injection. The fields can be final, the object never exists without its dependencies, and a test can pass mocks to the constructor with no container. A class with one constructor needs no @Autowired on it.
Use setter injection for optional dependencies. Avoid field injection, because it hides what a class needs and makes it hard to test without Spring.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are the different ways to configure Spring applications?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Spring supports three ways to configure an application: XML files, annotations on your classes, and Java configuration classes.
- XML-based configuration declares beans and their wiring in XML files. It appears mostly in older projects.
- Annotation-based configuration marks classes with
@Componentand injection points with@Autowired, and component scanning finds them. - Java-based configuration uses
@Configurationclasses whose@Beanmethods create beans.
// Java-based configuration
@Configuration
public class AppConfig {
@Bean
public UserService userService() {
return new UserService(userRepository());
}
@Bean
public UserRepository userRepository() {
return new UserRepository();
}
}
Most applications mix the last two. Annotations cover your own classes, and @Bean methods cover third-party classes you cannot annotate. Spring Boot can still load an old XML file with @ImportResource.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is @Autowired and how does it work?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
@Autowired tells Spring to inject a dependency automatically. Spring finds the bean whose type matches the field or parameter, which is matching by type, and passes it in.
You can put it on:
- constructors
- setter methods, and other methods with any name
- fields
- method parameters
@Service
public class UserService {
@Autowired
private UserRepository userRepository; // Field injection
@Autowired
public UserService(UserRepository userRepository) { // Constructor injection
this.userRepository = userRepository;
}
}
The example uses two places at once only to show both. In real code you pick one, usually the constructor. When a class has a single constructor, that constructor needs no @Autowired.
Every place Spring fills is required by default, so startup fails when no bean matches. Use @Autowired(required = false) or Optional for an optional dependency. When several beans match, choose one with @Qualifier or mark one bean @Primary.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is Spring Boot and what are its advantages?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Spring Boot is an opinionated framework on top of Spring that gets a production-ready application running with little setup. It follows convention over configuration, so it picks sensible defaults and you override only what you need.
Its main advantages:
- Auto-configuration creates beans from the libraries on the classpath, with no XML.
- Starter dependencies add a tested set of libraries with one dependency.
- An embedded server, Tomcat by default or Jetty, runs inside the app.
- The app ships as one executable JAR that starts with
java -jar. - Actuator adds health checks and metrics.
- Externalized configuration keeps settings in properties files and environment variables, outside the code.
The trade-off is that much happens implicitly, so you must know what to override when a default does not fit.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain @PathVariable, @RequestParam, and @RequestBody.
What is Spring Data and what are its key features?
What is Spring Security and what are its core features?
Explain authentication vs authorization in Spring Security.
What is Spring Initializr?
What is auto-configuration in Spring Boot? How does it work?
How do you configure different environments in Spring Boot?
What is Spring Boot Actuator and what are its key features?
How do you handle exceptions globally in Spring Boot?
What is Spring Data JPA and how do you use it in Spring Boot?
Explain the difference between @Autowired, @Inject, and @Resource.
How do you implement validation in Spring Boot?
What are Spring Boot profiles and how do you use them?
How do you configure and use caching in Spring Boot?
What is the difference between @Component and @Bean?
How do you implement security in Spring Boot?
How do you test Spring Boot applications?
What is the difference between @MockBean and @Mock?
How do you implement asynchronous processing in Spring Boot?
How do you implement custom health checks in Spring Boot Actuator?
How do you implement pagination and sorting in Spring Boot?
Explain Spring Boot's logging configuration.
How do you implement database migration in Spring Boot?
Explain Spring Boot's transaction management.
How do you implement file upload and download in Spring Boot?
What is the Spring IoC Container and what are its types?
Explain the different bean scopes in Spring.
Explain the Spring Bean lifecycle.
Explain Spring Boot application properties and profiles.
What is Spring MVC and how does its architecture work?
What is DispatcherServlet and what is its role?
Explain different types of controllers in Spring MVC.
Explain JpaRepository and its hierarchy.
How do query methods work in Spring Data JPA?
What is @Query annotation and when would you use it?
What are the different authentication methods in Spring Security?
What is Aspect-Oriented Programming (AOP) in Spring?
What are the different types of advice in Spring AOP?
What is @SpringBootTest and its different modes?
How do you test web controllers?
What happens when a Spring Boot application starts?
What is the difference between RestTemplate, WebClient and RestClient?
What is Spring Boot's approach to microservices?
What is Spring WebFlux and how does it differ from Spring MVC?
What is Spring Cloud and its key components?
Explain Spring Boot's auto-configuration process with @ConditionalOn annotations.
Explain Spring Boot's configuration precedence.
How do you implement custom auto-configuration in Spring Boot?
Explain Spring Security's filter chain.
How do you implement JWT authentication in Spring Security?
What is the difference between JDK dynamic proxy and CGLIB proxy?
Explain Spring's event handling mechanism.
What is @Conditional annotation and its use cases?
How does Spring handle circular dependencies?
What is Spring's ApplicationContext hierarchy?
Explain Spring's BeanPostProcessor and BeanFactoryPostProcessor.
What makes a Spring Boot application start slowly, and how do you fix it?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Spring Boot in pictures.
A quick recap of Spring Boot in 31 short animated pictures, one idea at a time. About 8 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 29 pictures come with Pro.
Spring Boot cheatsheet
- What Boot adds to Spring01
- Beans & injection02
- Properties & profiles03
- Auto-configuration04
- REST & Spring MVC05
- Data & transactions06
- Proxies, caching & async07
- Spring Security08
- Test at every layer09
- Production & microservices10
- The model11
- + 5 more inside
This picture is part of Pro. The first chapter is free to play; the other 29 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in62 of 72 Spring Boot answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.