1

I am new to spring mvc and DI. I have came to know about the flow of the spring project and i know how the web projects in spring mvc is developed and worked on few projects too. All the annotation uses and xml configuration files in the spring mvc. But i am confused where the DI is used? and how the DI is implemented in spring with the help of IOC??

Can anyone please explain me the concept of DI and IOC and their implementation in spring mvc.

Thanks in advance!!!

anishroniyar
  • 96
  • 12
  • I think the official Spring documentation does perfect justice to your question. – Marko Topolnik Jul 20 '15 at 09:43
  • By reading the documentation i have understood what the DI is, example the annotations we use such as @Autowired and others. They give the object or the class what they need instead of letting the object getting it by itself. But now my problem is to know about the difference between DI and IOC container with example. – anishroniyar Jul 20 '15 at 10:07
  • IoC container performs DI. – Marko Topolnik Jul 20 '15 at 10:09
  • This question and answers are just for you: http://stackoverflow.com/questions/6550700/inversion-of-control-vs-dependency-injection – mtyurt Jul 20 '15 at 10:46

1 Answers1

0

DI and IOC happening through web.xml where you created the dispatcherservlet. From Spring MVC docs : The DispatcherServlet, provides a shared algorithm for request processing while actual work is performed by configurable, delegate components The DispatcherServlet, as any Servlet, needs to be declared and mapped according to the Servlet specification using Java configuration or in web.xml. In turn the DispatcherServlet uses Spring configuration to discover the delegate components it needs for request mapping, view resolution, exception handling, and more.

internally it will register Spring mvc app and it will create an object and inject dependencies .

Ranga Reddy
  • 54
  • 1
  • 7