Spring Boot Interview Questions With Answer
Spring Boot Interview Questions With Answer
Spring Boot Interview Questions With Answer
Software Developers.
It is a Spring module that offers Rapid Application Development to Spring framework. Spring
module is used to create an application based on Spring framework which requires to configure
few Spring files.
Helps you to create a stand-alone application, which can be started using java.jar.
It offers pinpointed ‘started' POMs to Maven configuration.
Allows you to Embed Undertow, Tomcat, or Jetty directly.
Helps you to configure spring whenever possible automatically.
It is a web tool provided by Spring on its official website. However, you can also create Spring
Boot project by entering project details.
Starter dependency
Auto-configuration
Spring initializer
This is a frequently asked job interview. Various phases of RAD mode are:
Business Modeling: Based on the flow of information and distribution between various
business channels, the product is designed.
Data Modeling : The information collected from business modeling is refined into a set of
data objects that are significant for the business.
Application Generation: Automated tools are used for the construction of the software, to
convert process and data models into prototypes.
6) What is RAD model?
RAD or Rapid Application Development process is an adoption of the waterfall model; it targets
developing software in a short period. RAD follow the iterative
Business Modeling
Data Modeling
Process Modeling
Application Generation
Testing and Turnover
7) What are the commands to run and stop Spring Boot executable jar file?
java -jar
Example
To change the JDK version in Spring Boot, you can overwrite it by adding a java. version property
tag as given:
1.8
9) What is the process that you need to follow to run Spring Boot application on the custom
port?
In order to run a Spring Boot application, you require to put server.port properties in
application.properties. For example, server.port=8050
10) What is Spring Boot starter? How is it useful?
Spring Boot has many starters. They are a set of convenient dependency descriptors. Starter
allows you to include these descriptors in your pom.xml.
For example, If you want to work with Spring MVC, you can include “spring–boot–starter–web” as
a dependency in pom.xml.
11) Can you use Spring Boot with applications which are not using Spring?
12) What is the name of the configuration file which you can use in Spring Boot?
Spring Boot DevTools helps you to increase the productivity of the developer. So, you don't
require to redeploy your application every time you make the changes. It allows the developer to
reload changes without the need of restarting of the server.
Web Development
Spring Application
Application occasions and listeners
Admin highlights
YAML Support
Type-safe Configuration
Externalized Configuration
Properties Files
Logging and Security
You can define properties in the application.properties file exists in the classpath.
database.host=localhost
It is a special starter which makes Gradle or Maven dependency-management easy by adding jars
to your classpath.
Spring Boot Actuator allows you to monitor and manage your application when you want to push
it for the production. It helps you to control your application by using HTTP endpoints.
20) What is the command to run Spring Boot application to custom port?
server.port = 8181
21) How can you access a value defined in the application? What is properties file in Spring
Boot?
Use the @Value annotation to access the properties which is defined in the application -
properties file.
@Value("${custom.value}")
22) What is the primary difference between Spring and Spring Boot?
Spring is a web application development framework based on Java. On the other hand Spring
Boot is an extension of the spring framework which eliminated the boilerplate configuration
required for setup a Spring application.
23) Explain Spring Boot Admin
Spring Boot admin is a community project which helps you to manage and monitor your Spring
Boot applications.
24) How can you connect Spring Boot to the database using JPA?
Spring Boot supports spring-boot-data-JPA start, which helps you to connect spring application
with a relational database.
The @RestController annotation helps you to add @ResponseBody and @Controller annotations
to the class.
Spring initializer is a web application which can create an initial project structure for you.
Spring CLI is used for writing in Groovy Spring Boot application, which helps you to concise code.
You can define properties of Spring Boot into a file called application.properties. It helps you to
create this file manually, or you can use Spring Initializer to create this file.
1) Tomcat
2) Jetty
3) Undertow.
Thymelaf is a server-side Java template engine for a web application. It helps you to bring elegant
natural templates to your web application.
31) What are the Spring Boot properties?
Spring Boot offers various properties which can be specified inside our project's
application.properties file. It helps you to set values like a server-port number, database
connection configuration, etc.
The main difference between both of them is that JPA is a specification/Interface, whereas
Hibernate is only JPA implementations.
A shutdown is an endpoint that helps application to be shut down properly. This feature is not
enabled by default.
34) Is it possible to replace or override the Embedded Tomcat server in Spring Boot?
Yes, it is possible to replace the Embedded Tomcat with any other servers by using the starter
dependencies. For that, you can use spring-boot-starter-jetty or as a dependency for according
you to your need.
35) Can you disable the default web server in the Spring Boot application?
Yes, we can disable the default web server by using application.properties to configure the web
application type.
36) How do you Add, Filter to an application? There are three methods to add filter to Spring
Boot application:
Starters in Spring Boot are a set of convenient descriptors that are included in Spring Boot
applications. It comes with a variety of Spring-related technology which makes the entire process
of the application development much easier.
@PathVariable annotation helps you to extract information from the URI directly.
39) What is Swagger2?
Swagger is used to describing the structure of APIs. Swagger 2 is an open-source service provided
in Spring Boot which makes it easier for the machines to find out the structure of APIs like RESTful
Web services.
Dev
QA
Stage
Production
41) What are the major differences between RequestMapping and GetMapping?
RequestMapping can be used with GET, POST, PUT, and many other request methods using the
method attribute on the annotation. Whereas GetMapping is only an extension of
RequestMapping, which helps you to improve clarity on requests.
You can define properties in Spring Boot with the help of the application.properties file which
exists in a classpath of the application as follows.
Spring Initializr
Spring Boot CLI
Spring Starter Project Wizard
Profiles are used to separate various parts of your spring application configuration and make it
only available in certain environments.
To change the tomcat HTTP port, you have to change default HTTP property in
application.properties file.
Externalized Configuration helps to work with the same code in different environments.
Developers can use YAML files, properties files, command-line arguments, and environment
variables to externalize configuration.
It is a way to reload the changes without restarting Tomcat, or Jetty server. Eclipse and Many
other IDEs support bytecode hot swapping. If you make any changes that don’t affect the method
signature, it should reload without side effect.
In order to enable debug logging, you can specify --debug while starting the application from the
command prompt.
Spring Boot has lots of properties that can be easily overridden by specifying them in
application.properties.
The ELK Stack is made of three open-source products: 1) Elasticsearch, 2) Logstash, and 3) Kibana.
Spring Boot provides a very useful way to handle exceptions using @ControllerAdvice annotation.
Caching is a memory are that temporary stores frequently accessed data that is otherwise
expensive to get or compute.
Cross-Site Request Forgery attack or one-click attack is an attack that forces other users to
execute malicious commands on the application. CSRF attack specifically targets state-changing
requests.
Freemarker is a Java-based template used to generate plain text, emails, HTML file, etc.
Spring Boot Batch provides code reusability which is important when working with large numbers
of records, including transaction management, logging, skipping, job processing statistics, and job
restarts.
Apache Kafka is an open-source messaging platform. LinkedIn develops it. Apache Kafka enables
the user to build distributed applications and handle real-time data feeds. Kafka is suitable for
both offline and online messaging.
CORS stands for Cross-Origin Resource Sharing is a mechanism implemented by browsers and
helps users to authorize cross-domain requests. This mechanism serves as an alternative to less
secure and less powerful hacks of the kinds of IFrame or JSONP.
There are two types of dependency injection in Spring Boot. They are as follows:
Embedded containers help you to run Spring Boot application as a JAR from the command prompt
without setting up any web server, while to run a WAR you need first to set up Tomcat.
It is a traditional web application framework which helps you to build a web application. This
framework is similar to the framework of Struts.
It is a program execution point like the handling of an exception or the execution of a method. In
AOP, a join point is referred to as a method execution.
Pass this profile as an argument when you launch the Spring Boot application.
Set active the active profile in application.properties file.
71) Is excluding package without using the basePackages filter is possible? How?
Yes. It is possible to exclude package without using the basePackages filter by simply using the
exclude attribute while using the @SpringBootApplication annotation.
Install Java.
Install the Application Server.
Deploy the application war file.
Security
Parent
web
Thymeleaf
Freemarker