0% found this document useful (0 votes)
6 views

Spring Quetions Set - 3

The document discusses enabling the actuator in a Spring Boot application by adding the actuator dependency, enabling endpoints in application.properties, and running the application. This allows accessing actuator endpoints on the management port. It also discusses the @RequestMapping and @RestController annotations, how to get a list of beans, check environment properties, enable debugging logs, and the types of dependency injection.

Uploaded by

Mujif Attar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Spring Quetions Set - 3

The document discusses enabling the actuator in a Spring Boot application by adding the actuator dependency, enabling endpoints in application.properties, and running the application. This allows accessing actuator endpoints on the management port. It also discusses the @RequestMapping and @RestController annotations, how to get a list of beans, check environment properties, enable debugging logs, and the types of dependency injection.

Uploaded by

Mujif Attar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

28. How to enable Actuator in the Spring boot application?

Below are the steps to enable actuator in Spring Boot Application:


Add Actuator dependency.
Enable endpoints in application.properties.
Run your Spring Boot app.
Now we can access Actuator endpoints at URLs on the management port.

30. What are the @RequestMapping and @RestController annotations in Spring


Boot used for?

@RequestMapping: @RequestMapping is used to map HTTP requests to handler


methods in your controller classes. It can be used at the class level and method level. It
supports mapping by:
HTTP method – GET, POST, PUT, DELETE
URL path
URL parameters
Request headers
@RestController: @RestController is a convenience annotation that
combines @Controller and @ResponseBody. It indicates a controller where every
method returns a domain object instead of a view.
@RestController = @Controller + @ResponseBody
31. How to get the list of all the beans in your Spring boot application?

Using the ApplicationContext object in Spring Boot, we can retrieve a list of all the
beans in our application.
The ApplicationContext is responsible for managing the beans and their dependencies.

32. Can we check the environment properties in your Spring boot application
explain how?

Yes, we can check the environment properties in our Spring Boot Application. The
Environment object in a Spring Boot application can be used to check the
environment’s properties.
Configuration settings for the application, includes:
property files
command-line arguments
environment variables
We can get the Environment instance by calling the getEnvironment() method.
33. How to enable debugging log in the spring boot application?

To enable debugging log in Spring Boot Application, follow the below steps:
Add the logging level property to application.properties.
Configure the log pattern to include useful information.
Run the Spring Boot application.

Using the actuator endpoint, the log level can also be changed at runtime.
Curl -X POST \http://localhost:8080/actuator/loggers/<logger-name>
\ -H 'content-type: application/json' \-d '{"configuredLevel": "DEBUG"}'

34. What is dependency Injection and its types?

Dependency Injection (DI) is a design pattern that enables us to produce loosely


coupled components. In DI, an object’s ability to complete a task depends on another
object. There three types of dependency Injections.
Constructor injection: This is the most common type of DI in Spring Boot. In constructor
injection, the dependency object is injected into the dependent object’s constructor.
Setter injection: In setter injection, the dependency object is injected into the
dependent object’s setter method.
Field injection: In field injection, the dependency object is injected into the dependent
object’s field.

35. What is an IOC container?

An IoC (Inversion of Control) Container in Spring Boot is essentially a central manager


for the application objects that controls the creation, configuration, and management
of dependency injection of objects (often referred to as beans), also referred to as a DI
(Dependency Injection) container.
To know more about IOC Container, refer to the article – Spring – IoC Container

You might also like