Spring boot interview questions

Here are the frequently asked interview questions on spring boot

Q: Have you written Test cases using Spring Boot ?
A:
Spring Boot provides the @SpringBootTest for writing Unit Test Cases


Q: What is YAML ?
A:
YAML is a human-readable data serialization language. It is commonly used for configuration files.
Compared to properties file, YAML file is much more structured and less confusing in case we want to add complex properties in the configuration file. As can be seen YAML has hierarchical configuration data.

Q: How to implement security for Spring boot application ?
A:
For Implementing security for Spring Boot we use the spring-boot-starter-security dependency and have to add the Security config. It requires very little code. Config class will have to extend WebSecurityConfigurerAdapter and override its methods.


Q: Have you integrated Spring Boot and ActiveMQ ?
A:
For integrating Spring Boot and ActiveMQ we use the spring-boot-starter-activemq dependency
It requires very little configuration and no boilerplate code.


Q: Have you integrated Spring Boot and Apache Kafka ?
A:
For integrating Spring Boot and Apache Kafka we use the spring-kafka dependency.


Q: How to implement Pagination and Sorting with Spring Boot ?
A:
Using Spring Boot achieving pagination is very simple. Using the Spring Data-JPA this is achieved passing pageable org.springframework.data.domain.Pageable to the repository methods.


Q: What is Swagger ? Have you implemented it using Spring Boot ?
A:
Swagger is widely used for visualizing APIs, and with Swagger UI it provides online sandbox for frontend developers. For the tutorial, we will use the Springfox implementation of the Swagger 2 specification. Swagger is a tool, a specification and a complete framework implementation for producing the visual representation of RESTful Web Services. It enables documentation to be updated at the same pace as the server. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Thus Swagger removes the guesswork in calling the service.


Q: What is Spring Profiles ? How do you implement it using Spring Boot ?
A:
Spring Profiles allows users to register beans depending on the profile(dev, test, prod etc). So when the application is running in DEVELOPMENT only certain beans can be loaded and when in PRODUCTION certain other beans can be loaded. Suppose our requirement is that the Swagger documentation be enabled only for the QA environment and disabled for all others. This can be done using Profiles. Spring Boot makes using Profiles very easy.


Q: What is Spring Batch ? How do you implement it using Spring Boot ?
A:
Spring Boot Batch provides reusable functions that are essential in processing large volumes of records, including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management. It also provides more advanced technical services and features that will enable extremely high-volume and high performance batch jobs though optimization and partitioning techniques.Simple as well as complex, high-volume batch jobs can leverage the framework in a highly scalable manner to process significant volumes of information.


Q: What is FreeMarker Template? How do you implement it using Spring Boot ?
A:
FreeMarker is a Java-based Template Engine, originally focusing on dynamic web page generation with MVC software architecture. The major advantage of using Freemarker is the complete separation of the Presentation layer and the Business Layer. The Programmers can work on the application code while the designers can work on the html page design. Finally using freemarker these can then be combined to give the final output page.


Q: How to implement Exception Handling using Spring Boot ?
A:
Spring provides a very useful way to handle exceptions using ControllerAdvice.
We will be implementing a ControlerAdvice class which will handle all exceptions thrown by the controller class.


Q: What is caching? Have you used any caching framework with Spring Boot ?
A:
A cache is an area of local memory that holds a copy of frequently accessed data that is otherwise expensive to get or compute. Have used Hazelcast for caching.

Q: Have you exposed a SOAP webservice endpoint using Spring Boot?
A:
Yes. Using Spring Boot exposed a web service to be consumed. Used Contract first approach to generate the classes from wsdl.


Source:

Spring boot interview questions