Introduction to Spring Framework

                                                        Spring Tutorial

spring framework tutorial

Here in this  spring tutorial we will give in-depth concepts of Spring Framework with examples. Spring  Framework was developed by Rod Johnson in 2003. Spring framework makes the enterprise application development easy and fast.

This Tutorial is helpful  beginners and experienced persons.

 

Spring Framework Overview

Spring is a lightweight framework introduced by Rod Johnson in 2003 .  It can also be integrated with  other frameworks such as Hibernate, struts, EJB, JSF etc.

Spring framework has the following modules s IOC, AOP, DAO, Context, ORM, WEB MVC etc.  Let’s try to  understand the IOC and Dependency Injection first.

Inversion Of Control (IOC) and Dependency Injection

The design patterns that are used to remove dependency from the programming code. Which makes the code development  easy to test and maintain. Let’s  try to understand the  following code:

  1. class Employee{
  2. Address address;
  3. Employee(){
  4. address=new Address();
  5. }
  6. }

there is dependency between the Employee and Address (tight coupling). In the Inversion of Control scenario, we do this something like this:

  1. class Employee{
  2. Address address;
  3. Employee(Address address){
  4. this.address=address;
  5. }
  6. }

Thus, we can say  IOC makes the code  or part of the code  loosely coupled.

In Spring framework, IOC is a  container  and  responsible to inject the dependency. We provide metadata to the IOC container either by XML file or annotation.

 Let see the Advantage of Dependency Injection

  • It makes the code loosely coupled , so that easy to maintain
  • It makes the code easy to test.

 

Advantages of Spring Framework are:

 

1) Templates are predefined

Spring framework provides templates for struts,hibernate and  JDBC, JPA etc.  So there is no need to write specific framework or api  code. It hides the basic steps of these specific framework or api code.

 


2) Facility Loose Coupling

The  applications  developed in Spring framework considered to be  loosely coupled because of  the feature called IOC or say dependency injection.


3) Testing and maintenance are easy

Due to Dependency Injection applications developed in spring framework are  easier for testing and maintenance.


4) Lightweight

POJO implementation makes Spring framework to be considered as  lightweight .


5) Development is Faster

Due to the feature of dependency injection  and the facility to integrate with framework it helps developed faster delivery of applications.


6) Powerful abstraction

It provides powerful abstraction to JavaEE specifications such as JMS, JDBC, JPA and JTA.