The Ultimate Guide To Spring boot interview questions
At TechGeekNext, Spring Boot is one of our key focus area of our site, we provide number of technology article around Spring Boot.
In this article, we explore the Spring Boot Interview Questions & Answers for Experienced or Freshers. We are trying to share experience and learning to helps you advance your career as Spring Boot Developer.
- Q: What is Spring Boot?
- Q: What are the Advantages/Benefits of Spring Boot?
- Q: What are the features of Spring Boot?
- Q: How to create Spring Boot application using Spring Initializr?
- Q: What is Spring Boot dependency management?
- Q: What are the Spring Boot Starters?
- Q: What is the difference between Spring and Spring Boot?
- Q: Why Spring Boot is used for Microservices?
- Q: How Tomcat embed work in Spring Boot?
- Q: Does Spring Boot uses Spring MVC?
- Q: What is the difference between Spring MVC (@Controller and Spring RESTful (@RestController) web service?
- Q: What is @autowire in Spring?
- Q: What is @ResponseBody in spring boot?
- Q: What is @RequestMapping in spring boot?
- Q: What is @qualifier in spring?
Q: What is Spring Boot? Spring Boot Overview
Spring Boot is open source framework developed by Pivotal , used to build production ready standalone Spring application.
Q: What are the Advantages/Benefits of Spring?
- Pojo based, lightweight framework
- Support Lossly coupling
- Declarative Programming
- Support both XML/annotation configuration
Q: What are the Advantages/Benefits of Spring Boot?
- Can create standalone application.
- Eliminates the XML Configuration.
- Production ready application/features
- Provide Spring Boot Initializer project to start with new application
- Provides special starter (spring-boot-starter-parent), also provides dependency management section which eliminates version tags to define.
Q: What are the features of Spring Boot?
Spring Boot Components
- Spring Boot Initializer
- Starter POMs
- Spring Boot CLI
Q: How to create Spring Boot application using Spring Initializr?
Example of Spring Boot
- Go to Spring on official site (https://start.spring.io/).
- Select Maven project, add dependencies
- Click on Generate the project Button.
- Save and extract the project.
- Open IDE and import the project and click on browse and select the extracted project folder where pom.xml resides.
Q: What is Spring Boot dependency management? Spring Boot provided dependency management by which no need to provide versions for any dependencies, however if you want you can provide. Also it provide spring modules that you can use with Spring Boot as a refined list
of third party libraries. Spring Boot upgrades all dependencies automatically when you upgrade Spring Boot.
Q: What are the Spring Boot Starters? Spring Boot provides many build in starters which make development easier and fast. Starters are a set of dependency descriptors, which we can include in our application. For
example, spring-boot-starter-data-jpa, spring-boot-starter-actuator, spring-boot-starter-logging
Q: What is the difference between Spring and Spring Boot? The main difference in bootstrapping of the Spring and Spring Boot applications lies with the servlet.. Spring uses either the bootstrap entry point of the
web.xml or SpringServletContainerInitializer.On the other hand, only Servlet 3 features are used by Spring Boot to bootstrap an application.
Q: Why Spring Boot is used for Microservices? Spring Boot allows the quick construction of production-ready applications and offers non-functional features. It helps to configuring the components externally, helps
the various components. It has embedded servers with containers that are easy to deploy.
Q: How Tomcat embed work in Spring Boot? Spring Boot has a complete Tomcat included, so no need to install Tomcat externally . It builds a -jar with all the necessary needs.
You can use servers other than Tomcat externally.
java -jar spring-boot-sample.jar
Q: Does Spring Boot uses Spring MVC? If you wish to build a web application with Spring, you can use Spring MVC. However, for the production ready application , to minimizes the function, to monitor and manage the
application easily, you can use Spring Boot. Spring Boot can use Spring MVC and autoconfigure it.
Q: What is the difference between Spring MVC (@Controller and Spring RESTful (@RestController) web service?
Spring's MVC-based annotation framework simplifies the process of creating RESTful web services. The key difference between the traditional Spring MVC controller and the RESTful web service controller is how the HTTP response body is created.
Q: What is @autowire in Spring?
Spring framework autowiring function allows you to explicitly add the dependency of the object. Setter or constructor injection is used internally. It is not possible to use autowiring to inject primitive and string values. It only works by reference.
Q: What is @ResponseBody in spring boot?
Using the @ResponseBody annotation, Spring Boot web application sends data in JSON format.
Q: What is @RequestMapping in spring boot?
org.springframework.web.bind.annotation.RequestMappingis used to map web requests to different handler classes and/or handler methods.
Q: What is @qualifier in spring?
There may be a situation when you create more than one bean of the same type and with a property you want to wire only one of them. In such situations, by specifying which exact bean will be wired, you can use the @Qualifier annotation together with @Autowired
to eliminate the ambiguity.
Thymeleaf Interview Questions
Q: What is the use of Thymeleaf?
A: Thymeleaf is a Java XML / XHTML / HTML5 template engine which can operate in both web and non-web environments. It is best suited for serving XHTML / HTML5 on the view layer of MVC-based web applications, but even in offline environments it can process any XML document..
Q: What is spring boot starter Thymeleaf?
A: Thymeleaf is a library for Java. It is a template engine XML / XHTML / HTML5 that can apply a set of transformations to template files to display data and/or text generated by your applications.
Q: What is Thymeleaf Template?
A: For both web and standalone environments, Thymeleaf is a traditional server-side Java model engine.
Q: What is dialect in Thymeleaf?
A: The most simple interface for dialects, org.thymeleaf.dialect.IDialect, tells Thymeleaf only that dialect is a particular class. But the engine will need to know what that dialect can offer, and to declare that, one or more of a set of IDialect sub-interfaces will be implemented by the dialect class.
Q: What is Thymeleaf fragment?
A: A Fragment is a Template part Thymeleaf helps you to import this template fragments into another template. There are many ways to identify a fragment for you.
Q: how to use Spring request parameters with Thymeleaf?
A: Using th: object and th: field for binding information to a Java object in the Thymeleaf model and @ModelAttribute in the controller.