Q1. What is Spring Boot? And why it is used?
Ans. Spring boot is a framework which is designed by the Spring team which facilitates in creating the applications in much easier way. This provide spring module which has RAD (Rapid Application Development) feature. In other words, we can that spring boot is the extended version of the Spring framework which helps to solve all the previous problems faced by spring community.
>> Advantages of using this Spring Boot:
Q2. What is the difference between Spring and Spring Boot?
Ans. Spring is a framework helps in creating web applications. It provides tools and libraries which helps in creating a complete web application and it can be customized anytime.
Spring boot is a spring module which will create spring application that can just run.
Q3. How to create Spring Boot application using Maven?
Ans. Using Maven, we can create Spring Boot application:
Q4. What do you mean by spring boot starters?
Ans. Spring boot starters are nothing but a set of convenient dependency descriptors which can be included in applications.
Spring boot facilitate build-in starter which helps us in creating application much easier and faster.
Example of spring boot starters:
Q5. What is spring boot actuator?
Ans. Actuator is basically helps in managing and monitoring the applications. They provide “Management Endpoints” to see Application Internals, Metrics etc.
To enable Spring boot Actuator, Actuator dependency is added in POM file:
Q6. What is the difference between RequestMapping and GetMapping?
Ans. RequestMapping is generic in nature- Multiple request methods like GET, POST, PUT etc can be used easily using the method attribute on the annotation.
GetMapping is specified to only one functionality only that is Get request method. It’s just an extension of RequestMapping to improve clarity.
Q7. What is the way to reload changes on Spring boot without server-restart?
Ans. Any changes are reloaded in spring boot without starting the server by using dev tools.
Q8. How to run Spring boot application to custom port?
Ans. We need to specify the port in application.properties in order to run a spring boot application.
This entry will ensure that application would run on 8080 port.
Q9. Is it possible to write Test cases using Spring Boot?
Ans. Yes, it’s possible. Spring boot provides the @SpringBootTest annotation for writing Unit Test Cases.
Q10. What is the way to configure logging in Spring boot application?
Ans. Logging level can be easily specified in the application.properties files:
The above line present in application properties file will help us log to the debug level.
If a developer wants to put logs in the file, then the developer can specify logger file in application properties.
Apart from the above approaches, a developer can make a logback.xml file under main/java/resources and can specify the logging configuration in the file. Spring boot will automatically detect this file easily.
Q11. What is the way to implement Spring batch in spring boot?
Ans. Processing a batch involves processing large amount of data. Spring boot batch provides a function which is reusable and important for batch processing. It gives services and features which can be optimized and helps in partition techniques which results to give high performance batch jobs.
Any changes done in POM file will include necessary packages in application, which are required to process the batch in spring boot project.
Q12. What is the way to add custom JS code in Spring boot application?
Ans. A folder is created by the name “static” under the resources folder. Then all the static contents can be put into this folder.
The file can be referred in JSP like: <script src =”/js/test.js”></script>