Contents
What is Spring? INTRODUCTION
In the year 2003 Rod Johnson developed the spring which is open source platform for development to make the JavaEE application development in easy and rapid manner. Initially it was released in Apache 2.0.
Spring is a lightweight framework. It is otherwise called master of framework because it supports to other frameworks Struts, EJB, Hibernate and so on.This tutorial helps you to understand the spring framework in easy way.
Note: At the same time you have to get good knowledge in java and IDE such as Net Beans or Eclipse before this tutorial.
It consists of several modules
- OC
- AOP
- DAO
- Context
- ORM
- WEB MVC and so on.
Spring Versions:
- Spring Framework 1.0 (which released on March 2004)
- Spring Framework 1.2.6 (which released in the year 2006)
- Spring Framework 2.0 (which released on October 2006)
- Spring Framework 2.5(which released on November 2007)
- Spring Framework 3.0(which released on December 2009)
- Spring Framework 3.1(which released on December 2011)
- Spring Framework 3.2.5(which released on November 2013)
- Spring Framework 4.0(which released on December 2013)
- Spring Framework 4.2.0 (which released on 31 July 2015)
- Spring Framework 4.2.1 (which released on 01 Sept 2015)
- Spring Framework 4.3 (which released on 10 June 2016)
- Spring Framework 4.3.0.RC (up to 2019)
- Spring 5 (under build on)
Spring is especially designed for IOC and dependency Injection. By below you can understand what is IOC? And what is dependency Injection?
DEPENDENCY INJECTION WITH EXAMPLE:
Dependency injection helps us to work on our application to replace hardly coupled to loosely couple. In other words it helps to simplify the code from complications. There are three types of Dependency injections:
- Setter injection
- Construction injection
- Interface injection
Some versions in spring not support for Interface injection but Spring Version 2.X support all the injections.
IOC [Inversion of Control]
IOC is otherwise Inversion of control makes the code simpler and makes the code loosely coupled bean. Because of this Spring is Called Plain Old Java Object Framework( ie. POJO Framework)
Example:
class dog{ Animal animal; dog (){ Animal =new Animal (); } | Tightly coupled between Animal and Dog |
The above code can be written like this in IOC.
class dog { Animal animal; dog (Animal animal) { this.animal=animal; } } | Loosely Coupled |
The loosely couple code helps in different environment class without any change in the code or logic. This simplifies the process of writing code again and again, modification and testing.
ADVANTAGES OF SPRING
- Loosely coupled.
- Easy to test and modify.
- Simplify the development process.
- Templates are already predefined in it. (For framework like Hibernate, Struts, etc.)
- Light weight.
- Strong Abstraction (for JDBC, JMS etc…,)