Interview Questions.

Spring Boot Interview Questions and Answers


Spring Boot Interview Questions and Answers

Q1. What is Spring Boot?

Ans: Spring Boot is a contemporary framework from the team at Pivotal, designed to simplify the bootstrapping and improvement of a brand new Spring application. The framework takes an opinionated method to configuration, freeing developers from the need to outline boilerplate configuration. In that, Boot targets to be a front-runner inside the ever-expanding rapid application development space

Q2. What are Spring Boot Starter Projects?

Ans: Starters are a set of convenient dependency descriptors that you can include on your application. You get a one-stop-save for all of the Spring and related era that you need, without having to hunt through sample code and replica paste loads of dependency descriptors. For instance, if you want to get started out the usage of Spring and JPA for database get admission to, simply include the spring-boot-starter-information-jpa dependency in your task, and you are top to go.

Q3. What is Spring Boot Actuator?

Ans: Spring Boot Actuator is utilized by Spring Boot Framework to provide “Management EndPoints” to peer Application Internals, Metrics and many others

Q4. What is Spring Data?

Ans: Spring Data’s mission is to offer a acquainted and constant, Spring-based totally programming version for records get admission to whilst nevertheless retaining the special traits of the underlying information store. It makes it smooth to use statistics get entry to technologies, relational and non-relational databases, map-lessen frameworks, and cloud-based totally data offerings.

Q5. What is Spring Boot Starter?

Ans: Spring Boot Starters are simply JAR Files. They are used by Spring Boot Framework to provide “Auto-Dependency Resolution”.

Q6. What is Spring Boot AutoConfigurator?

Ans: Spring Boot AutoConfigurator is utilized by Spring Boot Framework to offer “Auto-Configuration”.

Q7. Mention  Spring Boot Components

Ans: Spring Boot Framework has the subsequent components:

Spring Boot Starter

Spring Boot AutoConfigurator

Spring Boot Actuator

Spring Boot CLI

Spring Boot Initilizr.

HubSpot Video

Q8. What is Spring Boot CLI?

Ans: In easy phrases, Spring Boot CLI is Auto Dependency Resolution, Auto-Configuration, Management EndPoints, Embedded HTTP Servers(Jetty,Tomcat and so forth.) and (Groovy,Auto-Imports)

Q9. What is Spring Boot Initilizr?

Ans: Spring Boot Initilizr is a Spring Boot device to bootstrap Spring Boot or Spring Applications very easily.

Spring Boot Initilizr comes inside the following paperwork:

Spring Boot Initilizr With Web Interface

Spring Boot Initilizr With IDEs/IDE Plugins

Spring Boot Initilizr With Spring Boot CLI

Spring Boot Initilizr With ThirdParty Tools

Q10. What is Spring Data REST?

Ans: Spring Data REST may be used to reveal HATEOAS RESTful resources round Spring Data repositories.

An example the usage of JPA is proven below

@RepositoryRestResource(collectionResourceRel = "todos", route = "todos")

public interface TodoRepository

        extends PagingAndSortingRepository<Todo, Long> 

Without writing a lot of code, we are able to divulge RESTful API around Spring Data Repositories.

Q11. What is the distinction between RequestMapping and GetMapping?


RequestMapping is prevalent - you could use with GET, POST, PUT or any of the alternative request techniques the use of the method characteristic on the annotation.

GetMapping is specific to GET request method. It’s simply an extension of RequestMapping to improve readability.

Q12. What and Why Embedded Servers?

Ans: Think approximately what you would need a good way to set up your application (commonly) on a digital system.

Step 1 : Install Java

Step 2 : Install the Web/Application Server (Tomcat/Websphere/Weblogic etc)

Step 3 : Deploy the application wa

Q13. Dependencies can be classified into:


Spring - core, beans, context, aop

Web MVC - (Spring MVC)

Jackson - for JSON Binding

Validation - Hibernate Validator, Validation API

Embedded Servlet Container - Tomcat

Logging - logback, slf4j

Q14.  How does path=”users”, collectionResourceRel=”customers” paintings with Spring Data Rest?


@RepositoryRestResource(collectionResourceRel = "customers", direction = "users")

public interface UserRestRepository extends

PagingAndSortingRepository<User, Long>

course - The route segment under which this resource is to be exported.

CollectionResourceRel - The rel price to apply whilst producing hyperlinks to the collection useful resource. This is used when generating HATEOAS links.

Q15. What are the alternative Starter Project Options that Spring Boot gives

Ans: Spring Boot also offers other starter initiatives inclusive of the standard dependencies to develop unique form of programs

spring-boot-starter-internet-services - SOAP Web Services

spring-boot-starter-net - Web & RESTful packages

spring-boot-starter-check - Unit checking out and Integration Testing

spring-boot-starter-jdbc - Traditional JDBC

spring-boot-starter-hateoas - Add HATEOAS capabilities for your offerings

spring-boot-starter-safety - Authentication and Authorization the use of Spring Security

spring-boot-starter-information-jpa - Spring Data JPA with Hibernate

spring-boot-starter-statistics-relaxation - Expose Simple REST Services the use of Spring Data REST

Q16. How does Spring allow creating manufacturing equipped programs in quick time?

Ans: Spring Boot aims to enable production geared up applications in short time. Spring Boot presents some non functional features out of the field like caching, logging, tracking and embedded servers.

Spring-boot-starter-actuator - To use advanced capabilities like tracking & tracing for your application out of the container

spring-boot-starter-undertow, spring-boot-starter-jetty, spring-boot-starter-tomcat - To pick out your particular desire of Embedded Servlet Container

spring-boot-starter-logging - For Logging the use of logback

spring-boot-starter-cache - Enabling Spring Framework’s caching aid

Q17. What is the minimal baseline Java Version for Spring Boot 2 and Spring five?

Ans: Spring Boot 2.Zero calls for Java 8 or later. Java 6 and 7 are no longer supported.

Q19. What is Auto Configuration?

Ans: The problem with Spring and Spring MVC is the amount of configuration this is needed.



 <property name="prefix">



 <property name="suffix">




 <mvc:resources mapping="/webjars/**" location="/webjars/"/>

Can we bring greater intelligence into this? When a spring mvc jar is delivered into an application, are we able to vehicle configure some beans routinely?

Spring Boot seems at a) Frameworks available on the CLASSPATH b) Existing configuration for the utility. Based on those, Spring Boot gives fundamental configuration needed to configure the software with these frameworks. This is referred to as Auto Configuration.

Q20. What happens inside the history when a Spring Boot Application is “Run as Java Application”?

Ans: If you are the use of Eclipse IDE, Eclipse maven plugin ensures that as quickly as you upload a dependency or make a exchange to the class report, it's miles compiled and ready inside the goal folder! And after that its similar to every other Java utility.

When you release the java application, then the spring boot car configuration magic kicks in.

It launches up tomcat when it sees that you are growing a web utility!

Q21. How do I trade the package call of a assignment in Spring Initializer?

Ans: Good news is you may customise it. Click the link “Switch to the entire model.“. You would be capable of configure the package deal name you will need!

Q22. What is the difference between JPA and Hibernate?

Ans: Short Story

JPA is a specification/Interface

Hibernate is certainly one of JPA implementations

When we use JPA, we use the annotation and interfaces from javax.Staying power bundle, with out the use of the hibernate import programs.

We advise the use of JPA annotations as we aren't tied to Hibernate as implementation. Later (I recognize - <1% Chance), we can use some other JPA implementation.

Q23. Why do we need spring-boot-maven-plugin?

Ans: spring-boot-maven-plugin provides a few instructions which allow you to package the code as a jar or run the utility

spring-boot:run runs your Spring Boot software.

Spring-boot:repackage repackages your jar/battle to be executable.

Spring-boot:begin and spring-boot:forestall to manage the lifecycle of your Spring Boot software (i.E. For integration assessments).

Spring-boot:build-information generates construct information that may be utilized by the Actuator.

Q24. In which layer, ought to the boundary of a transaction begin?

Ans: We endorse handling transactions within the Service layer. Logic for enterprise transactions is within the commercial enterprise/service layer and you will want to implement transaction management at that level

Q25. Why will we propose not to apply Spring Data Rest in actual global packages?

Ans: We think Spring Data Rest is Good for short prototyping! Be cautious approximately the use of this in Big packages!

With Spring Data REST you're exposing your database entitities without delay as REST Services.

When you design RESTful services, Best layout practices suggests that your interface should take into account  important things

Your Domain Model

Your Consumers

With Spring Data REST, you aren't considering both of those. You just reveal entities as REST Services.

Thats why we recommend to apply it for quick prototyping or the preliminary evolution of a project. It won't be a awesome idea for a totally advanced venture.