Spring Boot Interview Questions and Answers (2026)

Spring Boot starts a Spring application with starters, auto-configuration, and an embedded server. These are the answers to give in a fresher round, tied to one real API.

PragadeeshNovember 3, 2026
Spring Boot Interview Questions and Answers (2026)
Summarize this article in
Quick Answer
  • Spring Boot starts a Spring app with less setup. Say that a starter brings the libraries, auto-configuration builds the defaults, and an embedded server runs the API.

Short answer: Spring Boot is the way a Java team starts a Spring application without wiring every library by hand. In a fresher interview, say this first: a starter brings the dependencies, auto-configuration builds beans from what is on the classpath, and an embedded server lets you run the API with one command. Then give one example from your own project, such as a REST controller that saves a record through a service and a repository.

This page is a spoken guide for that round. It is not a copy of the Spring documentation. Use the Spring Boot documentation when you need the exact property name. Use this page to decide what to say, what to skip, and how to connect the answer to a project. If your Java basics are still thin, revise Java interview questions and the Java tutorial before you memorise annotations.

What does a Spring Boot interview actually test?

A fresher round rarely asks you to design a whole platform. The interviewer wants to know whether you understand the path of one request. A browser or a mobile app calls your URL. A controller receives it. A service applies the rule. A repository talks to the database. Spring Boot is the frame that makes those three layers start together.

Expect questions in this order: what Spring Boot is, how it differs from the Spring Framework, what a starter is, what auto-configuration means, how you configure a port or a database, how you return JSON, and how you would test one endpoint. If you have built even a small college project, they will ask you to walk through one class. Be ready to name the annotation on that class and the reason it is there.

  • Say what the annotation does, not only its name.
  • Name the layer: controller, service, or repository.
  • Say what happens when the input is wrong, not only the happy path.
  • If you did not use a feature, say so. Do not invent Redis, Kafka, or Kubernetes on a resume that only has a student API.

What is Spring Boot?

Spring Boot is an opinionated layer on top of the Spring Framework. It gives you a project structure, a set of starters, and auto-configuration so a web application can start with a main method. You still write Spring code. You write less setup code.

The line interviewers want is this: Spring Boot does not replace Spring. It starts Spring for you with sensible defaults. You override a default only when the default is wrong for your application, for example the server port or the database URL.

What is the difference between Spring and Spring Boot?

The Spring Framework is the core: dependency injection, MVC, transactions, and data access. Spring Boot is a convention for using that core. Without Boot, a team writes more configuration, chooses a server, and deploys a WAR to it. With Boot, the same application is often a JAR that contains an embedded server.

QuestionSpring FrameworkSpring Boot
What it isThe programming modelA way to start that model with defaults
SetupYou assemble dependencies and configurationStarters and auto-configuration do the first pass
How it runsOften a WAR on an external serverOften a JAR with Tomcat embedded
When you still need itAlways, because Boot is built on itWhen you want a short path from idea to a running API

Do not say "Spring is old and Boot replaced it." That answer is wrong. Boot is how most new Spring applications are created. The framework is still the thing your annotations call.

What does the @SpringBootApplication annotation do?

@SpringBootApplication is three annotations in one place. @Configuration marks the class as a source of bean definitions. @EnableAutoConfiguration turns on Boot's conditional setup. @ComponentScan tells Spring to find your @Component, @Service, @Repository, and @Controller classes in this package and below.

That last point is a common bug. If your main class sits in com.example.demo and a controller sits in com.other.api, the controller is not scanned. The application starts, and the URL returns 404. In the interview, say you keep the main class in the root package of the project so the scan covers every layer.

How does a Spring Boot application start?

The entry point is a main method that calls SpringApplication.run. That call creates the application context, reads your configuration, decides which auto-configurations apply, creates the beans, and starts the embedded server if the web starter is present. After that, the process waits for HTTP requests.

You can also mention CommandLineRunner or ApplicationRunner if your project runs a task once at startup, such as printing a ready message or loading a small lookup. Do not claim you customised the startup sequence unless you actually did. For a fresher project, "main calls run, the context loads, Tomcat listens" is a complete answer.

What is a Spring Boot starter?

A starter is a dependency that pulls in a coherent set of libraries. spring-boot-starter-web brings Spring MVC and an embedded Tomcat. spring-boot-starter-data-jpa brings Spring Data JPA and Hibernate. spring-boot-starter-test brings JUnit and the test helpers. You declare the starter. Maven or Gradle brings the versions Boot has tested together.

The point of the starter is not magic. It is a bill of materials so you do not guess which version of Jackson matches which version of Spring. If the interviewer asks why you did not list every jar, this is the answer.

What is auto-configuration?

Auto-configuration creates beans when the conditions match. If spring-boot-starter-web is on the classpath, Boot configures a dispatcher servlet and a JSON converter. If it also sees a DataSource, it can configure a transaction manager. The conditions live in classes you do not write. You see the result: beans that exist because a library is present and you did not define your own bean of that type.

Your own @Bean method wins when you define the same type. That is how you replace a default. Say it that way: auto-configuration is a default, and an explicit bean is an override. Interviewers like that sentence because it shows you will not fight the framework without a reason.

How do you turn an auto-configuration off?

Use the exclude attribute on @SpringBootApplication, or the property spring.autoconfigure.exclude. You do this when a starter pulled in a feature you do not want, or when a default bean clashes with a bean you must control yourself. Name one real case if you have it. If you have never excluded anything, say that the defaults were enough for the project and you would exclude only after reading the startup log.

The startup log and the /actuator/conditions endpoint, when Actuator is on, show which configurations matched and which did not. Mentioning that you would look there is better than inventing an exclude list.

Where do you put configuration?

application.properties and application.yml are the two common files. Both sit on the classpath, usually under src/main/resources. Properties are simple lines. YAML is easier to read when a setting has nested keys. Boot accepts either. Do not mix both for the same key and hope the winner is obvious. Pick one style for the project.

A value you must not commit, such as a database password, does not belong in the file you push to Git. Say you would use an environment variable or a secret held by the platform. That single sentence separates a student project from someone who has thought about a real server.

What are Spring profiles?

A profile is a named set of settings. application-dev.yml might point at a local database. application-prod.yml might point at the hosted one. You activate a profile with spring.profiles.active, often from the command line or the environment, not by editing the file on the server after every release.

In an interview, give one pair: local and production. Say what changes between them: the datasource URL, the log level, and whether SQL is printed. Do not say you used ten profiles if the project only ever ran on your laptop. One honest profile is enough.

What is an embedded server?

An embedded server is a server library inside your application, not a separate Tomcat you install and drop a WAR into. With spring-boot-starter-web, the default is Tomcat. The JAR's main method starts it. server.port changes the port. The usual local port in examples is 8080.

You can switch the starter to Jetty or Undertow if the project requires it. Most fresher projects never do. Knowing the default, and knowing the port property, is the answer they want. If they ask JAR versus WAR, say a JAR with an embedded server is the Boot default, and a WAR is for a team that must deploy onto a server they already operate.

What is the difference between @Controller and @RestController?

@Controller is a web controller. If you return a view name, Spring looks for a page. @RestController is @Controller plus @ResponseBody, so the return value is written as the response body, usually JSON. A fresher API project should use @RestController on the class that exposes endpoints.

Map the verb with @GetMapping, @PostMapping, @PutMapping, or @DeleteMapping. Say which status you return. A create that works is often 201. A missing record is 404. A validation failure is 400. You do not need every status code in the language. You need the four you actually used.

How does a request reach your code?

The embedded server accepts the HTTP call. The dispatcher servlet finds the controller method whose path and verb match. Arguments are filled from the path, the query, or the JSON body. The method returns an object. A message converter writes JSON. If an exception handler exists, a thrown exception becomes a clean error body instead of a stack trace.

Walk one route from your project while you say this. "POST /students with a JSON name and email hits StudentController, which calls StudentService, which calls StudentRepository.save." That walk is worth more than a list of annotations you have only read.

What is dependency injection in Spring?

Dependency injection means a class receives the objects it needs instead of constructing them with new. Spring creates the repository, creates the service, and passes the repository into the service. The service can be tested with a fake repository because it does not build the real one itself.

This is the same idea as the constructor you would write by hand, with the container doing the new. If your Java round already covered objects, connect the two answers. The Java constructor lesson is the language part. Spring is the container that calls those constructors.

Why do teams prefer constructor injection?

Constructor injection makes the required collaborators visible and lets you mark the fields final. The object cannot be built without its repository. Field injection with @Autowired hides that requirement and makes a plain unit test harder, because nothing in the constructor tells you what to pass.

Spring has not needed @Autowired on a single constructor for a long time. If the class has one constructor, Boot uses it. Say that if you remember it. If you only remember @Autowired on the constructor, that answer is still acceptable. Do not argue that field injection is "more Spring." It is only shorter to type.

What are the bean scopes?

The default scope is singleton. One bean instance is shared by the application context. Prototype creates a new instance each time the bean is requested. Request, session, and application scopes exist in web applications and are less common in a first project.

For a service and a repository, singleton is correct. They hold no per-user data in fields. If someone stores a user's name in a field of a singleton service, two requests can overwrite each other. That is the bug you should be able to describe. Keep request data in method arguments, not in fields of a shared bean.

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

All three mark a class for component scan. @Component is the general stereotype. @Service marks the business layer. @Repository marks the data layer and translates persistence exceptions into Spring's data-access exceptions. The names are how a reader finds the layer. Use them for that reason, not because the application fails to start without the more specific one.

A controller is @RestController or @Controller, not @Service. A class that only holds configuration properties is not a service. If the interviewer asks where a rule such as "email must be unique" lives, the answer is the service, with the repository doing the lookup.

How do you talk to a database with Spring Data JPA?

You write an interface that extends JpaRepository or a similar repository interface. You declare the entity. You add a method such as findByEmail. Spring Data implements the method from the name. You call it from the service. You do not write the SQL for the simple cases.

Know the cost of that convenience. findAll on a large table is not a feature. A method that loads every student so you can filter in Java is a bug. Say you would page the results or query for the rows you need. Also know that the entity is the table mapping, and it should not be the only object you return from a public API if the table has columns a caller must not see.

What does @Transactional do?

@Transactional draws a boundary. The methods inside it succeed together or fail together. If the service saves an order and then saves its lines, and the second save throws, the first save is rolled back when both calls sit in the same transaction.

Put the annotation on the service method, not on the controller, and not on a private method you call from the same class. A self-call does not pass through the Spring proxy, so the annotation on the private method never runs. That is a precise fresher answer and it is worth learning with one example, not as a slogan.

How do you validate input?

Put constraints on the request object: @NotBlank on a name, @Email on an email. Put @Valid on the controller argument. When the body fails, Spring raises a method-argument exception before your service runs. You handle that exception and return 400 with a short message that names the field.

Validation in the controller is for the shape of the request. A rule that needs the database, such as "this email is already registered," stays in the service. Say both. Interviewers listen for the split.

How do you handle errors?

A stack trace in the JSON is not an API. Use @ControllerAdvice with @ExceptionHandler methods for the exceptions you expect: validation, a missing record, and a conflict such as a duplicate email. Return a small body with a message and the status. Log the unexpected exception on the server.

You can also use ResponseStatusException for a one-off case. For a project with more than two endpoints, a single advice class is easier to explain in the interview because every error looks the same to the caller.

What is Spring Boot Actuator?

Actuator adds operational endpoints. /actuator/health says whether the process is up. Info, metrics, and the conditions endpoint help you see what auto-configuration did. You do not expose every endpoint on a public server. Health is the one a fresher should be able to name, and they should say the others stay limited.

If your project did not include Actuator, say that. Then say what you would add it for: a load balancer needs a URL that answers "this instance is alive" without calling the business API.

How do you test a Spring Boot API?

A unit test of the service uses JUnit and a fake repository. It does not start the server. A slice test with @WebMvcTest and MockMvc checks the controller: the path, the status, and the JSON, with the service mocked. A full @SpringBootTest starts the context and is slower. Use it for a few paths, not for every branch.

Name the style you actually used. "We called the service from a test and checked the saved name" is a real answer. "We had 100 percent coverage" is not, unless you can show the test that proves a failure case.

What should you say about Spring Security?

Spring Security is a filter chain in front of your controllers. Unauthenticated calls stop before the controller when a rule says they must. A fresher project often permits every URL, or permits GET and protects POST. Say which you did.

If you used HTTP Basic in a lab, say that it is a learning setup and not what you would ship for a public site. If you have not implemented login, do not describe token storage you have never built. Point at the filter idea, then stop. The interviewer can go deeper if they want. Guessing the rest is how a short question becomes a long failure.

How is the application packaged and run?

The Spring Boot Maven or Gradle plugin builds an executable JAR. java -jar app.jar starts it. The same JAR is what you would hand to a server or a container. The plugin repackages the archive so the main class and the dependencies are laid out the way Boot expects.

DevTools is a development convenience. It restarts the application when class files change. It is not part of the production run. Mention it only as a local tool. Production runs the JAR you built, with the production profile, and without DevTools on the classpath.

How do you explain a Spring Boot project in two minutes?

Use four beats. What the user can do. Which endpoint does that. Which class holds the rule. Which table stores the row. Then one failure: what the API returns when the email is blank or already used. Stop. Ask if they want the transaction or the tests next.

A weak walkthrough is a tour of the IDE. A strong one is a single request. Practise it out loud once before the round. If the project is on GitHub, know the exact controller name so you do not hunt for it while they watch.

Which mistakes do freshers repeat?

  • Putting business rules in the controller and leaving the service empty.
  • Returning the JPA entity from every endpoint, including fields that should stay private.
  • Catching every exception and returning 200 with an error string inside.
  • Calling findAll and filtering in a loop.
  • Storing a user id in a field of a singleton service.
  • Committing a real password in application.properties.
  • Saying "microservices" when the submission is one JAR and one database.

You can mention microservices as a direction: separate applications, talking over HTTP, each with its own Boot process. Do not draw a platform you have not run. One well-explained API beats a diagram of five services you cannot start.

How should you revise in the week before the interview?

Day one is Java: classes, collections, exceptions, and interfaces. The Spring answers assume those. Day two is the request path and the annotations on your own project. Day three is configuration, profiles, and the database repository. Day four is validation, errors, and one test. Day five is a spoken run-through of the project plus the difference between Spring and Spring Boot.

Keep a one-page sheet: the port, the base URL, two success calls, and two failures. If the round becomes a live coding task, you already know the shape. If it stays verbal, the sheet is your outline. The classroom version of this week, with someone watching the project, is what Java training in Chennai and the Java full stack syllabus are for. The interview page you are reading is the revision, not the whole course.

What should you read after this page?

Read the starter and auto-configuration chapters in the official Spring Boot documentation, then the data access chapter if your project uses JPA. When a property name is in doubt, the documentation wins over memory. For the Java language under the annotations, stay with the Java OOP lesson and the broader Java interview set. For the queries inside the repository, the SQL interview questions cover the joins your entity mapping hides.

In the room, answer the question you were asked. One clear path through controller, service, and repository is the Spring Boot answer that gets a fresher to the next round.

Frequently Asked Questions

What is Spring Boot in one sentence?
Spring Boot is a way to start a Spring application with starters, auto-configuration, and an embedded server so you write less setup code.
Does Spring Boot replace the Spring Framework?
No. Spring Boot uses the Spring Framework. It supplies defaults. You still write controllers, services, and repositories.
What is a starter?
A starter is a dependency that brings a tested set of libraries, such as spring-boot-starter-web for an API or spring-boot-starter-data-jpa for a database.
Where should business rules live?
In the service. The controller receives the request, the service applies the rule, and the repository talks to the database.
What if I have not used microservices?
Say so. Explain the one application you did run. Do not describe a platform you have never started.

Pragadeesh

Asmorix mentors share practical guidance on software, cloud, data, testing, and placement preparation for learners in Chennai.

View more posts

Call Now 81900 98289