13 Most Common Spring Boot Interview Questions
Spring framework is very popular frameworks widely used by experts to develop various web and enterprise applications. Spring has developed innumerable projects over time, and Spring Boot is one of them.
Below are some of spring boot interview questions you should prepare before appearing for an interview.
1. Why should you use spring boot?
Because it creates a spring application sooner and easily. For example, suppose that you have to create a spring boot project with ActiveMQ. For this, you’ll only use “spring–boot–starter–activemq” as artifact Id. What makes it easier is that it takes all the defaults and creates spring application with ActiveMQ configured. In case you don’t want to make use of inbuilt activeMQ, then it’s up to you to simply override “spring.activemq.broker-url” in the application and use external ActiveMQ.
2. What is the Spring Boot?
Spring Boot is an easy and convenient way to bootstrap or quickly create any spring application. It makes it easy for experts to create production-grade, stand-alone; spring based Applications that they can “just run.” Spring Boost comes with default configurations that help avoid much stressful boilerplate code.
3. What are the benefits of spring boot?
The advantages of spring boot are manifold. It provides many default configurations to create spring application faster. It has embedded tomcat or jetty server, so there is no need to deploy jar. It diminishes the stress of developing code by removing a lot of boilerplate code. Further, spring boot boosts productivity as you can create spring application quickly and provides you with many starter projects for easy maven integration. There is no need to worrying about version mismatch.
4. What are the drawbacks of spring boot?
There are no many drawbacks of spring boost. The only thing is that when you need to convert your old spring application to spring boost application, it may be time-consuming and not easy to do.
5. How can you run spring boot application on the custom port?
To run spring boot application on customer port, one needs to put the server.port properties in application.properties.
For instance: server.port=8050
6. How can you override default properties in spring boot Project?
Spring boot comes with some features and properties. To override these properties, one needs to specify them in application.properties.
Here is an example.
Suppose you have to specify prefix and suffix in Spring MVC applications. To do it, you need to put below properties in application.properties.
- mvc.view.prefix: /WEB-INF/
- mvc.view.suffix: .jsp
7. What is Spring boot starter?
Spring boot is designed to have a large number of starters. These starters are a set of convenient dependency descriptors. You can include these dependency descriptors in your pom.xml.
Let’s assume that you have to work on the Spring MVC application. In that case, you can simply include “spring–boot–starter–web” as a dependency in pom.xml.
8. Is it possible to use spring boot with non-spring boot applications?
No, it is not possible as of now. It’s important to know that spring boot is limited to Spring applications only.
9. Do you know how to use @SpringBootApplication annotation in spring boot project? If so, how?
@SpringBootApplication annotation was introduced in Spring Boot 1.2.0. This annotation is equal to declare these three annotations: @Configuration, @EnableAutoConfiguration, and @ComponentScan.
10 .Tell me the name of the configuration file used in spring boot?
Configuration file used in Spring boot projects is application.properties. It is a very important file as it is used to override all default configurations.
11. What is DevTools in spring boot?
Spring boot’s DevTools increases the work productivity of the developer. Using DevTools, you need not to use your application repeatedly every time you make the changes. Developers can reload the changes without restarting the server. Thus, there is no pain or hassle in redeploying application whenever you make any change.
12. What is the actuator?
It is one of the essential components of spring boot, used to access existing state of running the application in production environment. Developers use several different metrics to check the current state of the application. The spring boot actuator provides soothing web services endpoints which you can use and check various parameters.
13. Can you implement spring security in Spring boot application? If yes, how?
Implementing spring security in spring boot application requires little configuration. Just add a spring-boot-starter-security starter in pom.xml. Then, create spring config class which can extend WebSecurityConfigurerAdapter and override needed method to achieve security in spring boot application.
So, if you are preparing for java interview questions, remember the answers of spring boot interview questions.