1.What is the difference between constructor injection and setter injection?

Ans:-Setter based DI helps us to inject the dependency only when required,constructor injection for multiple field.We can easily change the value using setter injection.

 2.What is prototype bean?

Ans:-If the scope is declared prototype, then spring IOC container  will create  a new instance  of that bean every time a request is made for specific beans.

 3.What are the different type of Bean scope

Ans:-The extent of a bean characterizes the existence cycle and perceivability of that bean in the settings we use it.

The most recent rendition of the Spring system characterizes 6 kinds of extensions:

  • singleton:-Only 1 instance of spring bean will be created for the spring container.
  • prototype:-A New Instance will be created ever time the bean is requested from spring container.
  • request:-A new instance of beans will be created for each HTTP request.
  • session:-A new bean will be created for each HTTP session by the container
  • application
  • websocket/Global session:-This is used to create global beans for the Portlet applications.


 4.What is the difference between @Controller and @RestController?

Ans:-@Controller is used to mark class as spring MVC controller basically for UI purpose and @RestController is a special controller for RESTful web services.

 5.Do you know how the spring boot application works internally? 

Ans:-

 6.What is actuators.

Ans:-Spring Boot Actuator is a sub-project of the Spring Boot Framework. It includes a number of additional features that help us to monitor and manage the Spring Boot application. It contains the actuator endpoints (the place where the resources live). We can use HTTP and JMX endpoints to manage and monitor the Spring Boot application. If we want to get production-ready features in an application, we should use the Spring Boot actuator.

Spring Boot Actuator Features

There are three main features of Spring Boot Actuator:

Endpoints

Metrics

Audit

Endpoint: The actuator endpoints allows us to monitor and interact with the application. Spring Boot provides a number of built-in endpoints. We can also create our own endpoint. We can enable and disable each endpoint individually. Most of the application choose HTTP, where the Id of the endpoint, along with the prefix of /actuator, is mapped to a URL.

For example, the /health endpoint provides the basic health information of an application. The actuator, by default, mapped it to /actuator/health.  


Metrics: Spring Boot Actuator provides dimensional metrics by integrating with the micrometer. The micrometer is integrated into Spring Boot. It is the instrumentation library powering the delivery of application metrics from Spring. It provides vendor-neutral interfaces for timers, gauges, counters, distribution summaries, and long task timers with a dimensional data model.


Audit: Spring Boot provides a flexible audit framework that publishes events to an AuditEventRepository. It automatically publishes the authentication events if spring-security is in execution.


Enabling Spring Boot Actuator

We can enable actuator by injecting the dependency spring-boot-starter-actuator in the pom.xml file.


<dependency>  

    <groupId>org.springframework.boot</groupId>  

    <artifactId>spring-boot-starter-actuator</artifactId>  

    <version>2.2.2.RELEASE</version>  

</dependency>  

Spring Boot Actuator Endpoints

The actuator endpoints allow us to monitor and interact with our Spring Boot application. Spring Boot includes number of built-in endpoints and we can also add custom endpoints in Spring Boot application.

7.Spring Admin feathures

8.what are the different annotations you have used in Spring boot?

9.What is the flow of Spring MVC

10.What is IOC

11.What is the benefit of using spring boot ?

12.So how do you handle exceptions while using the spring or spring boot Framework

13. @RequestParam vs @PathVariable

14.What is ResponseEntity?, What are the benefit of using ResponseEntity?

15.Are you also having experience in Spring MVC? and what are the other modules of spring you have used?

16.What are the Spring framework modules?

Ans:-The basic modules of the Spring framework are :


Core module

Bean module

Context module

Expression Language module

JDBC module

ORM module

OXM module

Java Messaging Service(JMS) module

Transaction module

Web module

Web-Servlet module

Web-Struts module

Web-Portlet module.