Announcement Announcement Module
Collapse
No announcement yet.
Injecting as Property Vs Injecting as Constructor Arguments Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting as Property Vs Injecting as Constructor Arguments

    HI,

    Can any one help me the best way of injecting spring beans.
    In my project the pattern will be like
    Action<-->Service<-->DAO
    <-->Helpers classes

    Thanks

  • #2
    Concerning property vs. constructor injection I suggest the following approach:
    If a dependency is required for achieving a valid state of the bean at hand then it should be set in the constructor. If a dependency is optional, it is better assigned via a setter.

    Hope that helps,
    Andreas

    Comment

    Working...
    X