Introduction to Spring Boot

Last updated on May 30 2022
Amarjit Malik

Table of Contents

Introduction to Spring Boot

Page 1 Image 1 1
springboot

Spring Boot is a Spring module that provides the RAD (Rapid Application Development) feature to the Spring framework.

What is Spring Boot

Spring Boot is a project that is built on the top of the Spring Framework. It provides an easier and faster way to set up, configure, and run both simple and web-based applications.

It is a Spring module that provides the RAD (Rapid Application Development) feature to the Spring Framework. It is used to create a stand-alone Spring-based application that you can just run because it needs minimal Spring configuration.

Page 1 Image 2
configuration

In short, Spring Boot is the combination of Spring Framework and Embedded Servers.

In Spring Boot, there is no requirement for XML configuration (deployment descriptor). It uses convention over configuration software design paradigm that means it decreases the effort of the developer.

We can use Spring STS IDE or Spring Initializr to develop Spring Boot Java applications.

Why should we use Spring Boot Framework?

We should use Spring Boot Framework because:

  • The dependency injection approach is used in Spring Boot.
  • It contains powerful database transaction management capabilities.
  • It simplifies integration with other Java frameworks like JPA/Hibernate ORM, Struts, etc.
  • It reduces the cost and development time of the application.

Along with the Spring Boot Framework, many other Spring sister projects help to build applications addressing modern business needs. There are the following Spring sister projects are as follows:

  • Spring Data: It simplifies data access from the relational and NoSQL databases.
  • Spring Batch: It provides powerful batch processing.
  • Spring Security: It is a security framework that provides robust security to applications.
  • Spring Social: It supports integration with social networking like LinkedIn.
  • Spring Integration: It is an implementation of Enterprise Integration Patterns. It facilitates integration with other enterprise applications using lightweight messaging and declarative adapters.

Advantages of Spring Boot

  • It creates stand-alone Spring applications that can be started using Java -jar.
  • It tests web applications easily with the help of different Embedded HTTP servers such as Tomcat, Jetty, etc. We don’t need to deploy WAR files.
  • It provides opinionated ‘starter‘ POMs to simplify our Maven configuration.
  • It provides production-ready features such as metrics, health checks, and externalized configuration.
  • There is no requirement for XML configuration.
  • It offers a CLI tool for developing and testing the Spring Boot application.
  • It offers the number of plug-ins.
  • It also minimizes writing multiple boilerplate codes (the code that has to be included in many places with little or no alteration), XML configuration, and annotations.
  • It increases productivity and reduces development time.

Limitations of Spring Boot

Spring Boot can use dependencies that are not going to be used in the application. These dependencies increase the size of the application.

Goals of Spring Boot

The main goal of Spring Boot is to reduce development, unit test, and integration test time.

  • Provides Opinionated Development approach
  • Avoids defining more Annotation Configuration
  • Avoids writing lots of import statements
  • Avoids XML Configuration.

By providing or avoiding the above points, Spring Boot Framework reduces Development time, Developer Effort, and increases productivity.

Prerequisite of Spring Boot

To create a Spring Boot application, following are the prerequisites. In this tutorial, we will use Spring Tool Suite (STS) IDE.

  • Java 1.8
  • Maven 3.0+
  • Spring Framework 5.0.0.BUILD-SNAPSHOT
  • An IDE (Spring Tool Suite) is recommended.

Spring Boot Features

  • Web Development
  • SpringApplication
  • Application events and listeners
  • Admin features
  • Externalized Configuration
  • Properties Files
  • YAML Support
  • Type-safe Configuration
  • Logging
  • Security

Web Development

It is a well-suited Spring module for web application development. We can easily create a self-contained HTTP application that uses embedded servers like Tomcat, Jetty, or Undertow. We can use the spring-boot-starter-web module to start and run the application quickly.

SpringApplication

The SpringApplication is a class that provides a convenient way to bootstrap a Spring application. It can be started from the main method. We can call the application just by calling a static run() method.

  1. publicstatic void main(String[] args)
  1. {
  1. run(ClassName.class, args);
  1. }

Application Events and Listeners

Spring Boot uses events to handle the variety of tasks. It allows us to create factories file that is used to add listeners. We can refer it to using the ApplicationListener key.

Always create factories file in META-INF folder like META-INF/spring.factories.

Admin Support

Spring Boot provides the facility to enable admin-related features for the application. It is used to access and manage applications remotely. We can enable it in the Spring Boot application by using spring.application.admin.enabled property.

Externalized Configuration

Spring Boot allows us to externalize our configuration so that we can work with the same application in different environments. The application uses YAML files to externalize configuration.

Properties Files

Spring Boot provides a rich set of Application Properties. So, we can use that in the properties file of our project. The properties file is used to set properties like server-port =8082 and many others. It helps to organize application properties.

YAML Support

It provides a convenient way of specifying the hierarchical configuration. It is a superset of JSON. The SpringApplication class automatically supports YAML. It is an alternative of properties file.

Type-safe Configuration

The strong type-safe configuration is provided to govern and validate the configuration of the application. Application configuration is always a crucial task which should be type-safe. We can also use annotation provided by this library.

Logging

Spring Boot uses Common logging for all internal logging. Logging dependencies are managed by default. We should not change logging dependencies if no customization is needed.

Security

Spring Boot applications are spring bases web applications. So, it is secure by default with basic authentication on all HTTP endpoints. A rich set of Endpoints is available to develop a secure Spring Boot application.

Spring Boot Version

The latest version of Spring Boot is 2.0. It introduces a lot of new features along with some modifications and replacement.

Spring Boot 2.0

Let’s have a sneak peek at Spring Boot 2.0.

  • What’s New
    Infrastructure Upgrade
    Spring Framework 5
  • What’s Changed
    Configuration Properties
    Gradle Plugin
    Actuators endpoints
  • What’s Evolving
    Security
    Metrics

The pivotal team has upgraded the infrastructure in which the following tools are involved:

  • Supports Java 8 or above versions
  • Supports Apache Tomcat 8 or above versions
  • Supports Thymeleaf 3
  • Supports Hibernate 5.2

In Spring Framework 5, the Pivotal team upgraded the following:

  • Reactive Spring
    1. Servlet stack
      1. Servlet Container
      2. Servlet API
      3. Spring MVC
    2. Reactive Stack
      1. Netty, Servlet 3.1, Undertow
      2. Reactive HTTP Layer
      3. Spring WebFlux
  • Functional API
  • Kotlin Support

The latest version of Spring Boot is 2.2.1. This release of Spring Boot includes 110 fixes, dependency upgrades, and improvements.

In the Spring Boot v2.2.1, the annotation @ConfigurationProperties scanning is now disabled by default. We need to be explicitly opted into by adding the @ConfigurationPropertiesScan annotation.

New Features

  • Support constructor binding for property nested inside a JavaBean
  • Add config property for CodecConfigurer.maxInMemorySize in WebFlux
  • Make test slices’ type exclude filters public
  • Support amqps:// URIs in spring.rabbitmq.addresses

Dependency upgrades

Some dependencies have been upgraded in Spring Boot v2.2.1 are as follows:

  • Mongodb 3.11.2
  • Spring Security 5.2.1.RELEASE
  • Slf4j 1.7.29
  • Spring Hateoas 1.0.1.RELEASE
  • Hibernate Validator 6.0.18.Final
  • Hibernate 5.4.8.Final
  • Jetty 9.4.22.v20191022
  • Spring Framework 5.2.1
  • Spring AMQP 2.2.1
  • H2 1.4.200
  • Spring Security 5.2
  • Spring Batch 4.2

Some important and widely used third-party dependencies are upgraded in this release are as follows:

  • Micrometer 1.3.1
  • Flyway 6.0.7
  • Elasticsearch 6.8.4
  • JUnit 5.5
  • Jackson 2.10

Performance Improvements

In Spring Boot 2.2.1 the following performance has been improved:

Lazy Initialization

In Spring Boot 2.2.1, we can enable global lazy initialization by using the property spring.main.lazy-initialization property. It reduces the application startup time.

Java 13 Support

Spring Boot 2.2.1 now supports the latest version of Java that is Java 13.

Immutable Binding

In the newer version of Spring Boot, Configuration properties support constructor-based binding. The class annotates with @ConfigurationProperties annotation is to be immutable. It can be enabled by adding an annotation @ConfugurationProperties to a class or one of its constructors with @ConstructorBinding.

RSocket Support

It is a part of Spring Security. RSocket integration is auto-configured when an application finds spring-security-rsocket is present on the classpath.

Deprecations in Spring Boot 2.2

  • The property logging.file has renamed to logging.file.name.
  • The property logging.path has renamed to logging.file.path.
  • The server.connection-timeout property has been deprecated in favor of server-specific properties.
  • Joda time support is deprecated in favor of java.time.

The following improvements are made in the Spring Boot 2.2.1

  • Java: Spring Boot 2.2.1
  • Spring Framework 5.2: This release of Spring Boot upgrades to Spring Framework to 5.2.
  • JMX is disabled: In this version, JMX is not enabled by default. We can enable it by using the property jmx.enabled=true. If you are using the IDE feature to monitor your application, we need to enable it.
  • Fork enabled by default: Spring Boot application that ran by Maven Plugin is now forked by default.
  • JUnit 5: Spring Boot v2.2.1 provides JUnit 5 by default. JUnit 5’s vintage engine is also included by default that supports existing JUnit 4-based test classes. We can also use JUnit 4 and JUnit 5 based test classes in the same module.
  • AssertJ 3.12: This release of Spring Boot upgrades to AssertJ 3.12. It contains a breaking API changes for assertions related to Iterator.
  • Hibernate Dialect: In the newer version of Spring Boot, Hibernate chose the dialect to use rather than applying a default dialect based on the detected database.
  • Gradle Requirements: The latest version of Spring Boot requires Gradle 4.10.

So, this brings us to the end of blog. This Tecklearn ‘Introduction to Spring Boot’ blog helps you with commonly asked questions if you are looking out for a job in Java Programming. If you wish to learn Spring Boot and build a career Java Programming domain, then check out our interactive, Java and JEE Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/java-and-jee-training/

Java and JEE Training

About the Course

Java and JEE Certification Training is designed by professionals as per the industrial requirements and demands. This training encompasses comprehensive knowledge on basic and advanced concepts of core Java & J2EE along with popular frameworks like Hibernate, Spring & SOA. In this course, you will gain expertise in concepts like Java Array, Java OOPs, Java Function, Java Loops, Java Collections, Java Thread, Java Servlet, and Web Services using industry use-cases and this will help you to become a certified Java expert.

Why Should you take Java and JEE Training?

  • Java developers are in great demand in the job market. With average pay going between $90,000/- to $120,000/- depending on your experience and the employers.
  • Used by more than 10 Million developers worldwide to develop applications for 15 Billion devices.
  • Java is one of the most popular programming languages in the software world. Rated #1 in TIOBE Popular programming languages index (15th Consecutive Year)

What you will Learn in this Course?

Introduction to Java

  • Java Fundamentals
  • Introduction to Java Basics
  • Features of Java
  • Various components of Java language
  • Benefits of Java over other programming languages
  • Key Benefits of Java

Installation and IDE’s for Java Programming Language

  • Installation of Java
  • Setting up of Eclipse IDE
  • Components of Java Program
  • Editors and IDEs used for Java Programming
  • Writing a Simple Java Program

Data Handling and Functions

  • Data types, Operations, Compilation process, Class files, Loops, Conditions
  • Using Loop Constructs
  • Arrays- Single Dimensional and Multi-Dimensional
  • Functions
  • Functions with Arguments

OOPS in Java: Concept of Object Orientation

  • Object Oriented Programming in Java
  • Implement classes and objects in Java
  • Create Class Constructors
  • Overload Constructors
  • Inheritance
  • Inherit Classes and create sub-classes
  • Implement abstract classes and methods
  • Use static keyword
  • Implement Interfaces and use it

Polymorphism, Packages and String Handling

  • Concept of Static and Run time Polymorphism
  • Function Overloading
  • String Handling –String Class
  • Java Packages

Exception Handling and Multi-Threading

  • Exception handling
  • Various Types of Exception Handling
  • Introduction to multi-threading in Java
  • Extending the thread class
  • Synchronizing the thread

File Handling in Java

  • Input Output Streams
  • Java.io Package
  • File Handling in Java

Java Collections

  • Wrapper Classes and Inner Classes: Integer, Character, Boolean, Float etc
  • Applet Programs: How to write UI programs with Applet, Java.lang, Java.io, Java.util
  • Collections: ArrayList, Vector, HashSet, TreeSet, HashMap, HashTable

Java Database Connectivity (JDBC)

  • Introduction to SQL: Connect, Insert, Update, Delete, Select
  • Introduction to JDBC and Architecture of JDBC
  • Insert/Update/Delete/Select Operations using JDBC
  • Batch Processing Transaction
  • Management: Commit and Rollback

Java Enterprise Edition – Servlets

  • Introduction to J2EE
  • Client Server architecture
  • URL, Port Number, Request, Response
  • Need for servlets
  • Servlet fundamentals
  • Setting up a web project in Eclipse
  • Configuring and running the web app with servlets
  •  GET and POST request in web application with demo
  • Servlet lifecycle
  • Servlets Continued
  • Session tracking and filter
  • Forward and include Servlet request dispatchers

Java Server Pages (JSP)

  • Fundamentals of Java Server Page
  • Writing a code using JSP
  • The architecture of JSP
  • JSP Continued
  • JSP elements: Scriptlets, expressions, declaration
  • JSP standard actions
  • JSP directives
  • Introduction to JavaBeans
  • ServletConfig and ServletContext
  • Servlet Chaining
  • Cookies Management
  • Session Management

Hibernate

  • Introduction to Hibernate
  • Introduction to ORM
  • ORM features
  • Hibernate as an ORM framework
  • Hibernate features
  • Setting up a project with Hibernate framework
  • Basic APIs needed to do CRUD operations with Hibernate
  • Hibernate Architecture

POJO (Plain Old Java Object)

  • POJO (Plain Old Java Object)
  • Persistent Objects
  • Lifecycle of Persistent Object

Spring

  • Introduction to Spring
  • Spring Fundamentals
  • Advanced Spring

Got a question for us? Please mention it in the comments section and we will get back to you.

 

 

 

 

0 responses on "Introduction to Spring Boot"

Leave a Message

Your email address will not be published. Required fields are marked *