With Springs Dependency Injection, it is like providing or instantiating
appropriate object and provide it as a bean to the actual user/class.
Like for example, if project requires an additional data source in terms
of calling web service and receiving feeds apart from using existing
Database, then in my thinking the DAO layer has to change to accommodate
this new requirement/web service based data source, if DAO is directly
handling Hibernate specific dependencies.

But with Spring, it requires addition or modification in configuration
file so as to be able to inject appropriate data source (be it Hibernate
or web service), on demand.

Once we see some of the example of both these type of implementations,
this will be even much clearer.

While using Spring, there is a dependency to the way we create Beans.
With Spring, all the beans, those are configured in Spring related
configuration files, has to be instantiated by Spring framework only,
and one has to retrieve these beans from Spring Framework classes like
all concrete classes those implementing
org.springframework.beans.factory.BeanFactory interface from Spring,
such as XmlWebApplicationContext (in case of web based application),
FileSystemXmlApplicationContext (any Java based application which
has an access to local file system), ClassPathXmlApplicationContext
(resource or con fig file from class path) and many more.

So we can say Dependency Injection with Dependency to Spring.

So, I think, uses of Spring can become very much necessary when there
are many changes or plug and execute kind of implementation is desirable
in project/product.



Sandeep Joshi
Mathematics, Technology and Programming are my passion. I am a part of Java Ecosystem and through this blog, I contribute to it. I am here to blog about my interests, views and experiences.
I am on Google+ and Facebook.
I feel proud to be listed as a "National Memory Record Holder" in the Limca Book of Records, 2009 and have attempted for an International Memory record in the Guiness Book of Records. I can remember the value of PI upto 10,000 digits after the decimal (3.1415.....). You can contact me on javagenious.com(At)gmal.com ; I would like to hear from you :)