The Wayback Machine - https://web.archive.org/web/20240712225457/https://www.geeksforgeeks.org/introduction-to-spring-boot/
Open In App

Introduction to Spring Boot

Last Updated : 23 May, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Spring is widely used for creating scalable applications. For web applications Spring provides Spring MVC which is a widely used module of spring which is used to create scalable web applications. But main

disadvantage of spring projects is that configuration is really time-consuming and can be a bit overwhelming for the new developers.

Making the application production-ready takes some time if you are new to the spring. Solution to this is

Spring Boot

. Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming favourite of developer’s these days because of it’s a rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and set up. Spring Boot is a microservice-based framework and making a production-ready application in it takes very less time. Prerequisite for Spring Boot is the basic knowledge Spring framework. For revising the concepts of spring framework

read this article.

Features of Spring Boot

Spring Boot is built on the top of the conventional spring framework. So, it provides all the features of spring and is yet easier to use than spring.

  • It allows to avoid heavy configuration of XML which is present in spring: Unlike the Spring MVC Project, in spring boot everything is auto-configured. We just need to use proper configuration for utilizing a particular functionality. For example: If we want to use hibernate(ORM) then we can just add @Table annotation above model/entity class(discussed later) and add @Column annotation to map it to table and columns in the database
  • It provides easy maintenance and creation of REST end points: Creating a REST API is very easy in Spring Boot. Just the annotation @RestController and @RequestMapping(/endPoint) over the controller class does the work.
  • It includes embedded Tomcat-server: Unlike Spring MVC project where we have to manually add and install the tomcat server, Spring Boot comes with an embedded Tomcat server, so that the applications can be hosted on it.
  • Deployment is very easy, war and jar file can be easily deployed in the tomcat server:war or jar files can be directly deployed on the Tomcat Server and Spring Boot provides the facility to convert our project into war or jar files. Also, the instance of Tomcat can be run on the cloud as well.
  • Microservice Based Architecture: Microservice, as the name suggests is the name given to a module/service which focuses on a single type of feature, exposing an API(application peripheral interface). Let us consider an example of a hospital management system.
    • In case of monolithic systems, there will be a single code containing all the features which are very tough to maintain on a huge scale.
    • But in the microservice-based system, each feature can be divided into smaller subsystems like service to handle patient registration, service to handle database management, service to handle billing etc.

    Microservice based system can be easily migrated as only some services need to be altered which also makes debugging and deployment easy. Also, each service can be integrated and can be made in different technologies suited to them.

Evolution of Spring Boot

  1. Spring Boot came into existence when in October 2012, a client, Mike Youngstrom made a Jira request asking for bootstrapping the spring framework so that it can be quickly started. And hence in early 2013, Spring Boot was made.
  2. In April 2014, Spring Boot 1.0 was created followed by various versions.
  3. Spring Boot 1.1 on June 2014,
  4. 1.2 in March 2015,
  5. 1.3 in December 2016,
  6. 1.4 in January 2017 and
  7. Spring Boot 1.5 on February 2017.

Spring Boot Architecture

To understand the architecture of Spring Boot, let us first see different layers and classes present in it.

  • Layers in Spring Boot: There are four main layers in Spring Boot:
    • Presentation Layer: As the name suggests, it consists of views(i.e. frontend part)
    • Data Access Layer: CRUD (create, retrieve, update, delete) operations on the database comes under this category.
    • Service Layer: This consist of service classes and uses services provided by data access layers.
    • Integration Layer: It consists of web different web services(any service available over the internet and uses XML messaging system).
  • Then we have utility classes, validator classes and view classes.
  • All the services provided by the classes are implemented in their corresponding classes and are retrieved by implementing the dependency on those interfaces.

Spring Boot flow architecture

:

  • Since Spring boot uses all the features/modules of spring-like Spring data, Spring MVC etc. so the architecture is almost the same as spring MVC, except for the fact that there is no need of DAO and DAOImpl classes in Spring boot.
  • Creating a data access layer needs just a repository class instead which is implementing CRUD operation containing class.
  • A client makes the https request(PUT/GET)
  • Then it goes to controller and the controller mapped with that route as that of request handles it, and calls the service logic if required.
  • Business logic is performed in the service layer which might be performing the logic on the data from the database which is mapped through JPA with model/entity class
  • Finally, a JSP page is returned in the response if no error occurred.

Setup Spring Boot:

  1. Setup Java JDK from Oracle’s official site.
  2. Download and Setup Spring Tool Suite (STS).
  3. Start a new spring starter project
    • Click on File -> New -> Spring starter project
    • Fill the appropriate details and add dependency and finish.
    • Edit the application properties.
    • Run the main file as a Java application.

Previous Article
Next Article

Similar Reads

Difference Between Spring Boot Starter Web and Spring Boot Starter Tomcat
Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework
3 min read
Spring Boot - Spring JDBC vs Spring Data JDBC
Spring JDBC Spring can perform JDBC operations by having connectivity with any one of jars of RDBMS like MySQL, Oracle, or SQL Server, etc., For example, if we are connecting with MySQL, then we need to connect "mysql-connector-java". Let us see how a pom.xml file of a maven project looks like. C/C++ Code <?xml version="1.0" encoding=
4 min read
Spring vs Spring Boot vs Spring MVC
Are you ready to dive into the exciting world of Java development? Whether you're a seasoned pro or just starting out, this article is your gateway to mastering the top frameworks and technologies in Java development. We'll explore the Spring framework, known for its versatility and lightweight nature, making it perfect for enterprise-level softwar
8 min read
Java Spring Boot Microservices - Develop API Gateway Using Spring Cloud Gateway
The API Gateway Pattern in some cases stands for “Backend for frontend”. It is basically the entry gate for taking entry into any application by an external source. The pattern is going on in a programmer’s mind while they are making the client’s application. It acts as a medium between the client applications and microservices. For example-Netflix
4 min read
Spring Boot | How to access database using Spring Data JPA
Spring Data JPA is a method to implement JPA repositories to add the data access layer in applications easily. CRUD stands for create, retrieve, update, delete which are the possible operations which can be performed in a database. In this article, we will see an example of how to access data from a database(MySQL for this article) in a spring boot
4 min read
Difference between Spring MVC and Spring Boot
1. Spring MVC : Spring is widely used for creating scalable applications. For web applications Spring provides Spring MVC framework which is a widely used module of spring which is used to create scalable web applications. Spring MVC framework enables the separation of modules namely Model View, Controller, and seamlessly handles the application in
3 min read
How to Create a Spring Boot Project in Spring Initializr and Run it in IntelliJ IDEA?
Java language is one of the most popular languages among all programming languages. There are several advantages of using the java programming language, whether for security purposes or building large distribution projects. One of the advantages of using Java is that it tries to connect every concept in the language to the real world with the help
3 min read
How to Create and Setup Spring Boot Project in Spring Tool Suite?
Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework
3 min read
How to Run Your First Spring Boot Application in Spring Tool Suite?
Spring Tool Suite (STS) is a java IDE tailored for developing Spring-based enterprise applications. It is easier, faster, and more convenient. And most importantly it is based on Eclipse IDE. STS is free, open-source, and powered by VMware. Spring Tools 4 is the next generation of Spring tooling for the favorite coding environment. Largely rebuilt
3 min read
How to Make a Project Using Spring Boot, MySQL, Spring Data JPA, and Maven?
For the sample project, below mentioned tools got used Java 8Eclipse IDE for developmentHibernate ORM, Spring framework with Spring Data JPAMySQL database, MySQL Connector Java as JDBC driver.Example Project Using Spring Boot, MySQL, Spring Data JPA, and Maven Project Structure: As this is getting prepared as a maven project, all dependencies are s
4 min read
three90RightbarBannerImg