What is Spring Framework


What is Spring Framework?


Spring is an open source framework and inversion of control for Java Application.

Spring is dependency injection framework.

In an enterprise application many classes depend on many classes where we can take leverage using this framework by injecting this dependency.


Example


consider we have a pizza process for creating pizza

Class Pizza{


Pizza(){


……………….Steps for Making Pizza
}

}


Lets say we have OnlineRestaurantService{

CookService cs=new CookService(Pizza)

}


Here we are passing pizza dependency to CookService in OnlineRestuarantService class.

In future we can pass Hotdog service also in place of Pizza.

So this all can be done by Spring Framework.


How can we let CookService know to inject pizza as dependency or Hotdog as dependency.

Well using annotations

2 popular annotations are @component and @Autwired

@component tells manage OnlineRestuarantService dependency and @autowired tells you need to look for Pizza dependency for Cook Service.

We will see all annotations in our Annotation Library blog for Spring framework.

Comments

Popular posts from this blog

Integration Control

Zensar Java interview questions