0% found this document useful (0 votes)
36 views5 pages

Spring Boot

Uploaded by

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

Spring Boot

Uploaded by

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

WHAT IS SPRING BOOT?

Java Spring Boot (Spring Boot) is a tool that makes developing


web application and micro services with Spring Framework faster and
easier through three core capabilities:

 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 .

It provides a flexible way to configure Java Beans, XML configurations,


and Database Transactions.

It provides a powerful batch processing and manages REST endpoints.

In Spring Boot, everything is auto configured; no manual configurations


are needed.

It offers annotation-based spring application

Eases dependency management

It includes Embedded Servlet Container.


WHAT ARE STARTER FILES?
Before Spring Boot was introduced, Spring Developers used to spend a
lot of time on Dependency management. Spring Boot Starters were introduced
to solve this problem so that the developers can spend more time on actual code
than Dependencies. Spring Boot Starters are dependency descriptors that can
be added under the <dependencies> section in pom.xml. There are around 50+
Spring Boot Starters for different Spring and related technologies. These
starters give all the dependencies under a single name. For example, if you
want to use Spring Data JPA for database access, you can include spring-boot-
starter-data-jpa dependency.
The advantages of using Starters are as follows:

 Increase productivity by decreasing the Configuration time for developers.


 Managing the POM is easier since the number of dependencies to be added is
decreased.
 Tested, Production-ready, and supported dependency configurations.
 No need to remember the name and version of the dependencies.

DIFFERENCE BETWEEN MVC AND SPRING


BOOT
Spring MVC is a Model View, and Controller Spring Boot is built on top of the conventional
based web framework widely used to develop web spring framework, widely used to develop REST
applications. APIs.

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.

It takes more time in development. It reduces development time and increases


productivity.

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)

@Component Application components and their variants are automatically registered as


Spring Beans, providing dependency injection, provided you use either
@SpringBootApplication or @ComponentScan.

@Repository, @Controller, and @Service are move specific alternatives


to @Component.

@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.

@Controller @Controller is a specialized @Component marked as a controller in MVC


architecture.

@Repository This annotation marks a class as part of your data layer, for handling
storage, retrieval, and search..

@RestController @RestController combines the @Controller and @ResponseBody into a


single annotation. @RestController classes return domains instead of
views.

ANNOTATION (METHODLEVEL) DESCRIPTION

@PostMapping It maps the HTTP POST requests on the specific handler


method. It is used to create a web service endpoint that persist
data into database.

@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.

@DeleteMapping It maps the HTTP DELETE requests on the specific handler


method. It is used to create a web service endpoint that deletes a
resource.
ANNOTATION(RESPOSE DESCRIPTION
LEVEL)

@RequestParam It is used to extract the query parameters form the URL. It is


also known as a query parameter. It is most suitable for web
applications. It can specify default values if the query
parameter is not present in the URL.

@RequestBody It is used to bind HTTP request with an object in a method


parameter. Internally it uses HTTP MessageConverters to
convert the body of the request. When we annotate a method
parameter with @RequestBody, the Spring framework binds
the incoming HTTP request body to that parameter.(From Json
Body)

@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.

To Change the Port Number:


server.port=serverNumber
To define the name of our application you can write the properties like
this:
spring.application.name = Name.

You might also like