The Spring Framework is the most widely used Java framework, continuously evolving to keep up with modern architectures. Among its many projects, Spring Boot stands out as the most popular framework for building RESTful applications and microservices.
Preparing for Spring and Spring Boot interviews can be challenging due to the vast number of Spring modules and projects you need to know. A strong understanding of both the latest Spring features and the core principles applied in real-world projects is essential.
This course provides hands-on code examples covering 200+ Spring interview questions and answers, including topics on Spring Core, Spring Boot, Spring MVC, Spring JDBC, JPA, AOP, RESTful Services, and SOAP Web Services. It’s designed to help you build confidence and master the key concepts required for interviews.
GitHub Repository
https://github.com/in28minutes/spring-interview-guide
Presentation
- https://github.com/in28minutes/spring-interview-guide/raw/master/spring-interview-questions.pdf
What Will I Learn?
- Learn to answer 200+ interview questions on Spring, Spring Boot, and Spring MVC.
- Understand questions on the basics of JPA, Spring Data, Spring Data JPA, and Spring AOP.
- Learn to answer questions on RESTful Web Services and SOAP Web Services using Spring and Spring Boot.
- Master the basics of the Spring Framework, including IOC, Application Context, Dependency Injection, Bean Scope, and Component Scanning.
- Get familiar with essential Spring annotations:
@Component,@Service,@Repository,@Controller,@Autowired,@Primary,@Qualifier, and@PostConstruct. - Understand the core features of Spring Boot: Starters, Auto-Configuration, Actuator, and Externalized Configuration.
- Learn the best practices for using Spring and Spring Boot effectively.
- Explore approaches for handling validation errors in Spring MVC and Spring REST.
- Learn RESTful service strategies for versioning and content negotiation.
- Understand best practices for documenting RESTful services using Swagger.
A list of questions discussed for each topic is listed below.
Spring
- What is Loose Coupling?
- What is a Dependency?
- What is IOC (Inversion of Control)?
- What is Dependency Injection?
- Can you give a few examples of Dependency Injection?
- What is Auto Wiring?
- What are the important roles of an IOC container?
- What are BeanFactory and ApplicationContext?
- Can you compare BeanFactory with ApplicationContext?
- How do you create an ApplicationContext with Spring?
- How does Spring know where to search for components or beans?
- What is a Component Scan?
- How do you define a component scan in XML and Java configurations?
- How is it done with Spring Boot?
- What does
@Componentsignify? - What does
@Autowiredsignify? - What’s the difference between
@Controller,@Component,@Repository, and@Serviceannotations in Spring? - What is the default scope of a bean?
- Are Spring beans thread-safe?
- What other scopes are available?
- How is Spring’s singleton bean different from the Gang of Four (GoF) Singleton Pattern?
- What are the different types of Dependency Injection?
- What is Setter Injection?
- What is Constructor Injection?
- How do you choose between setter and constructor injections?
- What are the different options available to create ApplicationContexts for Spring?
- What is the difference between XML and Java Configurations for Spring?
- How do you choose between XML and Java Configurations?
- How does Spring do autowiring?
- What are the different kinds of matching used by Spring for autowiring?
- How do you debug problems with the Spring Framework?
- How do you solve NoUniqueBeanDefinitionException?
- How do you solve NoSuchBeanDefinitionException?
- What is
@Primary? - What is
@Qualifier? - What is CDI (Contexts and Dependency Injection)?
- Does Spring support CDI?
- Would you recommend using CDI or Spring annotations?
- What are the major features in different versions of Spring?
- What are the new features in Spring Framework 4.0?
- What are the new features in Spring Framework 5.0?
- What are the important Spring Modules?
- What are the important Spring Projects?
- What is the simplest way to ensure a single version of all Spring-related dependencies?
- Name some of the design patterns used in the Spring Framework.
- What do you think about the Spring Framework?
- Why is Spring popular?
- Can you give a big picture overview of the Spring Framework?
Spring MVC
- What is Model 1 architecture?
- What is Model 2 architecture?
- What is Model 2 Front Controller architecture?
- Can you show an example controller method in Spring MVC?
- Can you explain a simple request flow in Spring MVC?
- What is a ViewResolver?
- What is Model?
- What is ModelAndView?
- What is RequestMapping?
- What is DispatcherServlet?
- How do you set up DispatcherServlet?
- What is a form-backing object?
- How is validation done using Spring MVC?
- What is BindingResult?
- How do you map validation results to your view?
- What are Spring Form Tags?
- What is a Path Variable?
- What is a Model Attribute?
- What is a Session Attribute?
- What is an initBinder?
- How do you set the default date format with Spring?
- Why is Spring MVC so popular?
Spring Boot
- What is Spring Boot?
- What are the important goals of Spring Boot?
- What are the important features of Spring Boot?
- Compare Spring Boot vs Spring.
- Compare Spring Boot vs Spring MVC.
- What is the importance of
@SpringBootApplication? - What is Auto Configuration?
- How can we find more information about Auto Configuration?
- What is an embedded server? Why is it important?
- What is the default embedded server in Spring Boot?
- What are other embedded servers supported by Spring Boot?
- What are Starter Projects?
- Can you give examples of important starter projects?
- What is Starter Parent?
- What are the different things defined in Starter Parent?
- How does Spring Boot enforce common dependency management for all its starter projects?
- What is Spring Initializr?
- What is application.properties?
- What are some important things that can be customized in application.properties?
- How do you externalize configuration using Spring Boot?
- How can you add custom application properties using Spring Boot?
- What is
@ConfigurationProperties? - What is a profile?
- How do you define beans for a specific profile?
- How do you create an application configuration for a specific profile?
- How do you have different configurations for different environments?
- What is Spring Boot Actuator?
- How do you monitor web services using Spring Boot Actuator?
- How do you find more information about your application environment using Spring Boot?
- What is a CommandLineRunner?
Database Connectivity – JDBC, Spring JDBC & JPA
- What is Spring JDBC? How is it different from JDBC?
- What is a JdbcTemplate?
- What is a RowMapper?
- What is JPA?
- What is Hibernate?
- How do you define an entity in JPA?
- What is an EntityManager?
- What is a Persistence Context?
- How do you map relationships in JPA?
- What are the different types of relationships in JPA?
- How do you define One-to-One Mapping in JPA?
- How do you define One-to-Many Mapping in JPA?
- How do you define Many-to-Many Mapping in JPA?
- How do you define a datasource in a Spring context?
- What is the use of persistence.xml?
- How do you configure EntityManagerFactory and TransactionManager?
- How do you define transaction management for Spring–Hibernate integration?
Spring Data
- What is Spring Data?
- What is the need for Spring Data?
- What is Spring Data JPA?
- What is a CrudRepository?
- What is a PagingAndSortingRepository?
Unit Testing
- How does the Spring Framework make unit testing easy?
- What is Mockito?
- What is your favorite mocking framework?
- How do you create mock data with Mockito?
- What are the different mocking annotations you have worked with?
- What is MockMvc?
- What is
@WebMvcTest? - What is
@MockBean? - How do you write a unit test with MockMvc?
- What is JSONAssert?
- How do you write an integration test with Spring Boot?
- What is
@SpringBootTest? - What is
@LocalServerPort? - What is TestRestTemplate?
AOP
- What are cross-cutting concerns?
- How do you implement cross-cutting concerns in a web application?
- If you want to log every request to a web application, what are your options?
- If you want to track the performance of every request, what options do you have?
- What is an Aspect and a Pointcut in AOP?
- What are the different types of AOP advices?
- What is weaving?
- Compare Spring AOP vs AspectJ.
SOAP Web Services
- What is a Web Service?
- What is a SOAP Web Service?
- What is SOAP?
- What is a SOAP Envelope?
- What are SOAP Header and SOAP Body?
- Can you give an example of SOAP Request and SOAP Response?
- What kind of information is sent in a SOAP Header?
- Can you give an example of a SOAP Header with authentication information?
- What is WSDL (Web Service Definition Language)?
- What are the different parts of a WSDL?
- What is Contract-First Approach?
- What is an XSD?
- Can you give an example of an XSD?
- What is JAXB?
- How do you configure a JAXB Plugin?
- What is an Endpoint?
- Can you show an example endpoint written with Spring Web Services?
- What is a MessageDispatcherServlet?
- How do you configure a MessageDispatcherServlet?
- How do you generate a WSDL using Spring Web Services?
- How do you implement error handling for SOAP Web Services?
- What is a SOAP Fault?
RESTful Web Services
- What is REST?
- What are the key concepts in designing RESTful APIs?
- What are the best practices for RESTful services?
- Can you show code for an example GET Resource method with Spring REST?
- What happens when we return a bean from a RequestMapping method?
- What is GetMapping and what are related methods in Spring MVC?
- Can you show code for an example POST Resource method with Spring REST?
- What is the appropriate HTTP Response Status for successful resource creation?
- Why do we use ResponseEntity in a RESTful service?
- What is HATEOAS? Can you give an example response?
- How do we implement HATEOAS using Spring?
- How do you document RESTful web services?
- What is Swagger Documentation?
- How do you automate the generation of Swagger documentation from RESTful web services?
- How do you add custom information to Swagger documentation?
- What is Swagger-UI?
- What is the “representation” of a resource?
- What is Content Negotiation? Which HTTP header is used?
- How do we implement content negotiation using Spring Boot?
- How do you add XML support to your RESTful services in Spring Boot?
- How do you implement exception handling for RESTful web services?
- What are best practices for handling exceptions in RESTful web services?
- What are the different error statuses to return in RESTful web services?
- How would you implement them using Spring Boot?
- What HTTP response status should you return for validation errors?
- How do you handle validation errors in RESTful web services?
- Why do we need versioning for RESTful web services?
- What versioning options are available?
- How do you implement versioning for RESTful web services?

