Table of Content

  • What is Spring Framework and its history
  • Why Spring Framework
  • Spring Modules
  • Design Patterns
  • Spring Fundamentals ie Bean,Container etc
  • Build Tool: Maven
  • Spring Boot Introduction
  • Hello World with Spring Boot

What is spring framework

Spring framework is an open source Java platform based framework. It was initially written by Rod Johnson and was first released under the Apache 2.0 license in June 2003.

Spring is the most popular application development framework for enterprise java.

Spring is lightweight when it comes to size and transparency. The basic version of Spring framework is around 2MB.

Spring is not just a framework. It's also a complete ecosystem of supporting frameworks and tools that provide you everything you need to build complex applications. It provides support for various common things that most enterprise applications need, like connecting to the database, managing business services, security and so on.

​

Why Spring Framework

Lightweight
Loose Coupling
​Dependency Injection
Cache/Validation/Transaction
Easy Testing
Moduler programming
Simplicity- Pojo Based
Testability
RAD(Rapid Application Development)
JDBC/Hibernate Templates
JDBC Exception Handling
Transaction Management
Spring framework is non-invasive:=>  It means that it does not force the developers to implement or extend the Spring API in application.
 

Spring Modules

Spring Core,
Spring MVC,
Spring Rest Web Services,
Spring Cloud,
Spring Hateoas,
Spring data-jpa
Spring Security(Basic and Outh)

Design Pattern

 Dependency injection or inversion of control (IOC)
Factory Design Pattern:
Proxy Design Pattern
Singleton Design Pattern:
Model View Controller (MVC):

Bean Introduction

Spring Bean is nothing special, any object in the Spring framework that we initialize through Spring container is called Spring Bean. Any normal Java POJO class can be a Spring Bean if it’s configured to be initialized via container by providing configuration metadata information.

How to create Bean

Spring Framework provide three ways to configure beans to be used in the application.
  1. Annotation Based Configuration – By using @Service or @Component annotations. Scope details can be provided with @Scope annotation.
  2. XML Based Configuration – By creating Spring Configuration XML file to configure the beans. If you are using Spring MVC framework, the xml based configuration can be loaded automatically by writing some boiler plate code in web.xml file.
  3. Java Based Configuration – Starting from Spring 3.0, we can configure Spring beans using java programs. Some important annotations used for java based configuration are @Configuration, @ComponentScan and @Bean.

IOC Container or Spring Container

The Spring IoC Container creates, configures and connects the objects (which are called Beans), then manage their life cycle. The IoC container is responsible to instantiate, configure and assemble the objects. The IoC container gets informations from the XML file and works accordingly. The main tasks performed by IoC container are:

to instantiate the application class to configure the object to assemble the dependencies between the objects There are two types of IoC containers. They are:

1)BeanFactory 2) ApplicationContext
Difference between Bean Factory and Application Context.

Subtitle

Build Tool

Build tool is a program that automates the process of compiling, testing ,packaging and deploying of source code in the most efficient manner

Maven

Maven is a Java tool, so you must have Java installed in order to proceed.

First, download Maven and follow the installation instructions.

 

POM File:-

 

POM means Project Object Model is key to operate Maven. Maven reads pom.xml file to accomplish its configuration and operations.
 

It is an XML file that contains information related to the project and configuration information such as dependencies, source directory, plugin, goals etc. used by Maven to build the project.

POM.XML File

  1. mvn clean install

  2. mvn clean test

  3. mvn clean package

  4. mvn spring-boot:run

Maven basic Commands

Demo

  1. Java 8+ Version
  2. Java Application Build Tool Like Maven,Gradle
  3. IDE- IntelljIdea,Eclipse 
  4. ZIP Extraction Tool

 

Pre requisite to run Application

Spring Boot

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

 

Spring Boot does not generate code and there is absolutely no requirement for XML configuration.

It uses convention over configuration software design paradigm that means it decrease the effort of developer.

Advantage of Spring Boot

  • Embed Tomcat, Jetty or Undertow directly. You don't need to deploy WAR files.

  • It provides opinionated 'starter' POMs to simplify your Maven configuration.

  • It automatically configure Spring whenever possible.

  • It provides production-ready features such as metrics, health checks and externalized configuration.

  • Absolutely no code generation and no requirement for XML configuration.

How to Exclude Server

Title Text

Subtitle

spring-introduction

By Sagar Mal Shankhala