Springbootnotes
Springbootnotes
Sprint boot is a Java-based spring framework used for Rapid Application Development
(to build stand-alone microservices). It has extra support of auto-configuration
and embedded application servers like tomcat, jetty, etc.
Is it possible to change the port of the embedded Tomcat server in Spring Boot?
Yes, it is possible to change the port of the embedded Tomcat server in a Spring
Boot application.
The simple way is to set the server. port property in your application’s
application.properties file. For example, to set the port to 8081, add the
following property to the application.properties file:
Can we disable the default web server in the Spring Boot application?
Yes, we can disable the default web server in the Spring Boot application. To do
this, we need to set the server.port property to “-1” in the application’s
application.properties file.
Describe the flow of HTTPS requests through the Spring Boot application.
First client makes an HTTP request (GET, POST, PUT, DELETE) to the browser.
After that the request will go to the controller, where all the requests will be
mapped and handled.
After this in Service layer, all the business logic will be performed. It performs
the business logic on the data that is mapped to JPA (Java Persistence API) using
model classes.
In repository layer, all the CRUD operations are being done for the REST APIs.
A JSP page is returned to the end users if no errors are there.
What are the actuator-provided endpoints used for monitoring the Spring boot
application?
Actuators provide below pre-defined endpoints to monitor our application -
Health
Info
Beans
Mappings
Configprops
Httptrace
Heapdump
Threaddump
Shutdown
How to get the list of all the beans in your Spring boot application?
Spring Boot actuator “/Beans” is used to get the list of all the spring beans in
your application.
Setter Injection: The IOC container will inject the dependent bean object into the
target bean object by calling the setter method.
Constructor Injection: The IOC container will inject the dependent bean object into
the target bean object by calling the target bean constructor.
Field Injection: The IOC container will inject the dependent bean object into the
target bean object by Reflection API.
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