DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Spring Dependency Injection

Spring Dependency Injection

Himanshu Gupta user avatar by
Himanshu Gupta
·
Jul. 08, 10 · Java Zone · Interview
Like (0)
Save
Tweet
5.28K Views

Join the DZone community and get the full member experience.

Join For Free

spring di is the most fundamental feature that spring provides. this feature has also been referred as inversion of control but after many discussions it was decided that di is a better term.

any application which is of practical use is composed of two or more objects which communicate with, or use, each other.  traditionally each of those objects is responsible to get the reference of objects it uses but in di objects are given references to the other objects when needed. all the bean creation and their injection are handled by spring which acts as a container of beans. this provides loose coupling and also promotes programming to an interface as the bean knows only about the type of bean but nothing about its implementation.

for example : if the bean store has declared product property as an interface then the product implementation becomes irrelevant.   the product bean can be web-service implementation, an ejb or a mock test object.

some other benefits of using di:
• reduction of boiler plate coding.
• as all metadata is in xml file and is easy to configure. this gives flexibility in testing and development.

from http://himanshugpt.wordpress.com/2010/07/05/spring-dependency-injection/

Spring Framework Dependency injection

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Java’s Encapsulation - When the Getter and Setter Became Your Enemy
  • How BDD Works Well With EDA
  • Practice on Pushing Messages to Devices of Different Manufacturers
  • How To Use Open Source Cadence for Polling

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo