mostly asked spring boot interview questions

What is Spring boot actuator?

Spring Boot Actuator provides additional features for monitoring and managing applications when pushed to production by developers. HTTP or JMX end points may be used for this purpose.

How does spring boot actuator work?

Spring Boot incorporates several additional features for monitoring and managing applications when pushed to production via JMX or HTTP endpoints. Health, auditing and metrics gathering may be automatically applied to applications. Several production-ready features attributed to Spring Boot are offered by the spring-boot-actuator. The easiest means of enabling the features is by adding a specific dependency ‘Starter’ termed spring-boot-starter-actuator.

What is spring boot in java?

Spring Boot, launched by the team at Pivotal, is a framework designed for simplifying bootstrapping and the development of new Spring applications. It showcases an opinionated approach towards configuration and frees developers from the process of defining a boilerplate configuration.

What is spring boot transaction management?

Transaction management serves to be a significant part of RDBMS-oriented enterprise applications. It ensures consistency and data integrity. An abstract layer is provided by the

Spring framework on top of various transaction management APIs. The transaction support system of Spring is aimed at providing an alternative to numerous EJB transactions. It does so by adding different transaction capabilities to POJOs. Both declarative transaction management and programmatic transaction management are supported by spring. Contrary to EJBs that necessarily require application servers, Spring transaction management is capable of being implemented even without an application server.

What is @restcontroller in spring boot?

@RestController was introduced by Spring 4.0 as a specialized version and convenience-based annotation of the controller. It is responsible for adding the @ResponseBody and @Controller annotations. When the controller class is annotated with @RestController annotation, the @ResponseBody annotation may not be included in the request mapping methods. Do note that the @ResponseBody annotation will be active by default.

What is @requestmapping in spring boot?

@RequestMapping refers to the commonest annotation in the repository of Spring Web applications. It maps HTTP requests for handling the methods of REST and MVC

controllers.

What is @qualifier in spring boot?

The @Qualifier annotation is used in situations wherein more than a singular type of bean is created and only one needs to be wired with a property. The @Qualifier annotation can be used along with @Autowired for removing the confusion and specifying the exact beans that have to be wired.

How to Deploy Spring Boot WAR to Tomcat?

Say, you want to deploy and run a WAR file in Tomcat. The following steps will help your cause:

Download Apache Tomcat.
Unpackage the same into the desired tomcat folder.
Copy the WAR file from the target/spring-boot-tomcat.war into the tomcat/webapps/ folder.
From a terminal, go to tomcat/bin folder.
Execute the file.

Explain different types of Spring boot annotations?

The different Spring boot annotations are as follows:

@SpringBootApplication

It is used for marking the main class of any Spring Boot. The @SpringBootApplication is known to encapsulate @EnableAutoConfiguration@Configuration and the @ComponentScan annotations along with their default properties and attributes.

@EnableAutoConfiguration

@EnableAutoConfiguration paves the ground for auto-configuration. Spring Boot searches for auto-configuration beans on the classpath of @EnableAutoConfiguration and applies them automatically.

@ConditionalOnMissingClass and @ConditionalOnClass

When these conditions are used, Spring uses the marked auto-configuration beans in case the class representing the argument in the annotation’s argument is either present or absent.

@ConditionalOnMissingBean and @ConditionalOnBean

These annotations are useful for defining conditions on the basis of the absence or presence of specific beans.

@ConditionalOnProperty

This spring boot annotation allows developers to make conditions based on the values of properties.

@ConditionalOnResource

This spring boot annotation allows the use of a definition in case a specific resource is available.

@ConditionalOnNotWebApplication and @ConditionalOnWebApplication

These annotations help in the creation of conditions on the basis of whether a particular application is web-based or not.

@ConditionalExpression

This spring boot application is useful in more complex situations that are true/ false on the basis of given conditions.

@Conditional

A class that evaluates custom conditions in complex conditions uses the annotation @Conditional.

More:

Spring boot interview questions with answers