What is Spring?

Here we see some points:
  • Spring is LightWeight framework and also a container that can be used to developed enterprised application   eaisly.
  • Spring can developed the Enterprised application using the web server but before that if u want to do J2EE application you have to use the application server.
  • At the lowest level, Java applications used  of Java interfaces and classes. where these classes and interfaces which interact with each other to provide services.These objects are dependent on each other, and we call an object dependent.                      
Let  see through Example------

class Traveller

{

  Public staic void main(String ar[])


    {

          Car c=new Car();
           c.move();
  }

class Car

{

   public void move()


    {


       system.out.println("move");


     }


}


In this code- class Traveller is depend on the class Car.

How we see now-if you want to change the class Car in future 

with Truck or like MotorBike than this code will  get affected 

with the reference side and object creation both side.

Let me improve this code thorough Interface.

class Traveller

{

  Public staic void main(String ar[])


    {

       
   Vehicle v=new Car();

           c.move();


  }


Interface Vehicle
{
   void move();
}

class Car implements Vehicle
{

  public void move()


    {


       system.out.println("move");


     }


  }


Now you see in this code little bit improve.
Here if you want to change in the class Car name than reference side will not get affect but object creation side will still affected.

Through simple java classs and Interface you cant reduce this dependency.
Spring framework provide this facility and introduced the loose coupling between the classes.
Let see How------------

public class Traveller
 { 
    public staic void main(String ar[])
    {
       ApplicationContext ctx=new

                       ClassPathXmlApplicationContext("spring.xml");
          
                       Vehicle v=(Vehicle)ctx.getBean("vehicle");
                  
                       v.move();
       }
 }


spring.xml


<bean id ="vehicle" class="Car"/>

Now if you want to change the class Car in future you can easily 

change because there is not direct dependency between class Car 

and class Vehicle.

Here you are inject the dependency through the bean..

Spring take the all responsibility to create the instance of bean class 

and wiring between the object.