Interview questions
Spring Boot Interview Questions
20 Spring Boot interview questions with model answers: auto-configuration, beans, @Transactional, Actuator, testing and microservices. For both sides.

What's here
20 Spring Boot interview questions, grouped into 4 areas: core concepts, beans, configuration and transactions, web, data, testing and operations and microservices with spring. Each one comes with why it is worth asking and what a strong answer contains, so the same question can be scored the same way by different interviewers.
- Ask for an example where auto-configuration did something unexpected and how they found out why.
- Use the @Transactional self-invocation trap as a quick test of whether the candidate understands proxies.
- Give a slow endpoint scenario backed by JPA and ask how they would diagnose it.
Cohesyve finds, contacts and tests Spring Boot candidates on the real work, then ranks them for these interviews. 14-day free trial for 10 candidates, not charged until it ends.
Preparing for this interview yourself? Practise it free →These Spring Boot interview questions cover what Java backend interviews test on the Spring framework and Spring Boot: auto-configuration and starters, dependency injection and bean scopes, configuration and profiles, transactions, REST and data access, testing, Actuator, and the microservices questions that often follow. Candidates can use the 'what to look for' notes as model answers; interviewers can use them as a scoring guide.
Core Concepts
What Spring Boot does on top of the Spring Framework, and how it wires an application together.
- 1
What does Spring Boot add on top of the Spring Framework?
Why ask it
Separates people who use Spring Boot from people who understand it.What to look for
Auto-configuration based on what is on the classpath, starter dependencies that bundle compatible libraries, embedded servers so an app runs as a single executable, externalised configuration, and production features through Actuator. The Spring Framework still provides the core: dependency injection, MVC, transactions. - 2
What does the @SpringBootApplication annotation do?
Why ask it
Every Spring Boot app starts with it.What to look for
It combines three annotations: @SpringBootConfiguration (a configuration class), @EnableAutoConfiguration (turns on auto-configuration) and @ComponentScan (scans for components in the class's package and below). Good candidates explain why the main class usually sits in the root package. - 3
How does auto-configuration work, and how do you override it?
Why ask it
Debugging Spring Boot means understanding what it configured for you.What to look for
Auto-configuration classes create beans conditionally, for example only when a class is on the classpath or when no bean of that type exists yet. You override by defining your own bean, setting properties, or excluding an auto-configuration class. The conditions report (debug mode) shows what was applied and why. - 4
What is a Spring Boot starter?
Why ask it
Basic, but reveals how the candidate thinks about dependencies.What to look for
A dependency descriptor that pulls in a tested set of libraries for a purpose, such as a web, data JPA or test starter, so versions work together. Strong answers mention dependency management through the Spring Boot parent or BOM. - 5
What are the ways to inject dependencies, and which do you prefer?
Why ask it
Shows design habits and testability awareness.What to look for
Constructor, setter and field injection. Constructor injection is preferred: dependencies are explicit, can be final, and the class is easy to test without a container. Field injection hides dependencies and makes testing harder.
Before the Spring Boot interviews, see who can do the work
Cohesyve finds and contacts Spring Boot candidates from your job description and tests each one on an AI job simulation of the role, so these questions go to a ranked shortlist. 14-day free trial for 10 candidates, not charged until it ends.
Beans, Configuration and Transactions
How beans live and behave, and the proxy-based features that cause the most surprises.
- 6
What bean scopes does Spring support, and which is the default?
Why ask it
Scope mistakes cause shared-state bugs.What to look for
Singleton (the default: one instance per container), prototype (a new instance each time), and web-aware scopes: request, session, application and websocket. Singletons must be stateless or thread-safe. A prototype bean injected into a singleton is created only once unless you use a provider or lookup. - 7
What is the difference between @Component, @Service, @Repository and @Bean?
Why ask it
Basic Spring vocabulary.What to look for
@Component marks a class for component scanning; @Service and @Repository are specialisations that signal intent, and @Repository also enables translation of persistence exceptions. @Bean is used on a method in a configuration class to create a bean, typically for third-party classes you cannot annotate. - 8
How do you manage configuration across environments?
Why ask it
Every real app runs in several environments.What to look for
application.properties or YAML, with profile-specific files and active profiles; environment variables and other external sources that override packaged defaults; typed binding with @ConfigurationProperties. Secrets come from environment configuration or a secret store, never from committed files. - 9
How does @Transactional work, and why does it sometimes do nothing?
Why ask it
A classic Spring trap that catches experienced developers.What to look for
Spring wraps the bean in a proxy that starts and commits or rolls back a transaction around the method. Calling a transactional method from another method in the same class bypasses the proxy, so no transaction starts. By default rollback happens on unchecked exceptions, not checked ones. Good answers mention propagation and read-only transactions. - 10
Which bean lifecycle hooks have you used?
Why ask it
Shows experience with initialisation and cleanup.What to look for
@PostConstruct and @PreDestroy, InitializingBean and DisposableBean, or initMethod and destroyMethod on @Bean. Typical uses: warming a cache, validating configuration, closing resources. Strong answers keep heavy work out of constructors.
Web, Data, Testing and Operations
Building, testing and running a Spring Boot service in production.
- 11
How would you build a REST endpoint with validation and consistent error responses?
Why ask it
Everyday Spring Boot work.What to look for
@RestController with mapping annotations, request DTOs validated with Bean Validation annotations and @Valid, and a @ControllerAdvice with exception handlers that return a consistent error body and correct status codes. Do not expose JPA entities directly in the API. - 12
What are common performance problems with Spring Data JPA?
Why ask it
Data access is where most Spring apps slow down.What to look for
N+1 queries from lazy relationships, loading whole entities when a projection would do, eager fetching everywhere, and missing indexes. Fixes: fetch joins or entity graphs, DTO projections, pagination, and checking the generated SQL. - 13
What is Spring Boot Actuator, and how do you expose it safely?
Why ask it
Operations and security in one question.What to look for
Actuator provides production endpoints such as health, metrics, info and environment details. By default only the health endpoint is exposed over HTTP. Expose others deliberately, secure them with Spring Security, and consider a separate management port. - 14
How do you test a Spring Boot application?
Why ask it
Testing approach shows maturity.What to look for
Plain unit tests for business logic without Spring; slice tests such as @WebMvcTest for controllers and @DataJpaTest for repositories; @SpringBootTest for full integration tests, often with real databases in containers. Strong candidates keep the expensive full-context tests few. - 15
What do you check when upgrading a Spring Boot application to a new major version?
Why ask it
Upgrades are a regular job for Spring teams.What to look for
Minimum Java version (Spring Boot 4.x requires Java 17 or later and Spring Framework 7), changed or removed properties and APIs in the release notes and migration guide, third-party library compatibility, and running the full test suite. Upgrade in steps rather than jumping several versions with no tests.
Microservices with Spring
Spring Boot interviews often move on to microservices design. These questions test judgement more than annotations.
- 16
When would you split a monolith into microservices, and when would you not?
Why ask it
Tests architectural judgement.What to look for
Split when parts of the system need independent deployment, scaling or ownership by separate teams, along clear business boundaries. Avoid it when the team is small or boundaries are unclear, because microservices add network failure, data consistency and operational overhead. A modular monolith is a valid answer. - 17
How should services communicate: synchronous REST calls or messaging?
Why ask it
Communication choices drive reliability.What to look for
Synchronous calls are simple but couple availability: if one service is down, callers fail. Messaging through a broker decouples services and smooths load but adds eventual consistency and harder debugging. Good answers pick per use case and mention idempotent consumers. - 18
How do you make a service resilient when a dependency is slow or down?
Why ask it
Cascading failures are a common microservices outage.What to look for
Timeouts on every remote call, retries with backoff for safe operations, circuit breakers (for example with Resilience4j), bulkheads to limit shared resources, and fallbacks where sensible. Candidates should warn that retries without timeouts make outages worse. - 19
How do you keep data consistent across services without a distributed transaction?
Why ask it
A core distributed-systems problem.What to look for
Each service owns its data. Use the saga pattern (a series of local transactions with compensating actions) and the transactional outbox pattern so database changes and published events stay in step. Accept eventual consistency and design the user experience for it. - 20
How do you trace a request across several Spring Boot services?
Why ask it
Debugging microservices depends on observability.What to look for
Distributed tracing that propagates trace and span IDs through headers, structured logs that include the trace ID, metrics through Micrometer, and a central place to search logs and traces. Health checks and dashboards per service complete the picture.
Running the interview well
- 1Ask for an example where auto-configuration did something unexpected and how they found out why.
- 2Use the @Transactional self-invocation trap as a quick test of whether the candidate understands proxies.
- 3Give a slow endpoint scenario backed by JPA and ask how they would diagnose it.
- 4Keep microservices questions grounded: ask about a real failure in a system they worked on.
- 5Check the candidate's Java fundamentals as well, since Spring knowledge sits on top of them.
- 6Let candidates look up exact annotation names; score understanding of what happens at runtime.
Common questions
What Spring Boot topics are asked most in interviews?
Auto-configuration, starters, @SpringBootApplication, dependency injection, bean scopes, profiles and configuration, @Transactional, REST controllers, Spring Data JPA, testing and Actuator. Senior interviews add microservices.
How should I prepare for a Spring Boot interview?
Build a small REST service with validation, JPA, tests and Actuator, then practise explaining what Spring does at startup. Be ready to discuss a transaction or performance problem you solved and to answer core Java questions.
What is the difference between Spring and Spring Boot?
The Spring Framework provides the core features: dependency injection, MVC, data access and transactions. Spring Boot builds on it with auto-configuration, starters, embedded servers and production tooling, so you can get an application running with far less setup.
Which Java version does Spring Boot need?
Spring Boot 4.x requires at least Java 17 and Spring Framework 7. Check the system requirements page in the Spring Boot documentation for the exact version you use.
Are microservices questions part of Spring Boot interviews?
Often, especially for mid-level and senior roles. Expect questions on service boundaries, communication, resilience, data consistency and observability.
Do Spring Boot interviews include coding?
Many do: a small REST endpoint, a service with tests, or a code review exercise spotting issues such as field injection, missing validation or N+1 queries.
Save these questions for the Spring Boot candidates who can do the work
Cohesyve takes your Spring Boot job description, finds candidates, reaches out to them and runs an AI job simulation of the real work, then returns a ranked shortlist.
1,500+
assessments completed
50%
faster time-to-hire
5 min
from JD to assessment
14-day free trial · 10 candidates · Not charged until the trial ends
Preparing for a Spring Boot interview yourself? Practise on an AI job simulation of the role. 3-day free trial, cancel anytime.
From the blog