Spring Boot
Spring Boot
Autoconfiguration.
An opinionated approach to configuration.
The ability to create standalone applications.
These features work together to provide you with a tool that allows
you to set up a Spring-based application with minimal configuration and
setup.
Why spring boot?
You can choose Spring Boot because of the features and benefits it
offers as given here .
If we are using Spring MVC, we need to build the If we are using Spring Boot, there is no need to
configuration manually. build the configuration manually.
Spring MVC specifies each dependency separately. It wraps the dependencies together in a single unit.
Spring MVC framework consists of four There are four main layers in Spring Boot:
components : Model, View, Controller, and Front Presentation Layer, Data Access Layer, Service
Controller. Layer, and Integration Layer.
Spring MVC do not provide powerful batch Powerful batch processing is provided by Spring
processing. Boot.
Ready to use feature are provided by it for Default configurations are provided by it for
building web applications. building a Spring powered framework.
IMPORTANT ANNOTATIONS IN SPRING
BOOT
ANNOTATION(CLASS DESCRIPTION
LEVEL)
@Service This is an alternative to @Component that specifies you intend to use the
class as part of your service layer. However, it doesn’t actually implement
anything differently than @Component.
@Repository This annotation marks a class as part of your data layer, for handling
storage, retrieval, and search..
@GetMapping It maps the HTTP GET requests on the specific handler method.
It is used to create a web service endpoint that fetches data from
database.
@PutMapping It maps the HTTP PUT requests on the specific handler method.
It is used to create a web service endpoint that creates or updates
data.
@PathVariable It is used to extract the values from the URI. It is most suitable
for the Restful web service, where the URL contains a path
variable. We can define multiple @PathVariable in a method.
Application.properties File
In a spring boot application, application.properties file is used
to write the application-related property into that file. This file contains
the different configuration which is required to run the application in a
different environment, and each environment will have a different
property defined by it. Inside the application properties file, we define
every type of property like changing the port, database connectivity and
many more.