Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Thanks Tomasz.Point1:- Does spring give runtime error in case of circular dependency? Point2:-Just trying to understand with example.Are you saying that if i have class A which is using Class B as dependency in its constructor(class B does not implement interface).Wont it be possible? Commented Oct 16, 2011 at 5:53
  • 7
    Think about it: if bean A requires an instance of bean B on startup and bean B requires an instance of bean A, there is no way to instantiate them. When Spring detects such a situation it throws an exception when starting. However with setter/field injection Spring can firdt create instances and then inject them, no problem in this situation. Commented Oct 16, 2011 at 8:20
  • 3
    If this is a common problem in your project, though, then you probably have other things to worry about than DI style. Commented Oct 16, 2011 at 21:54