Results 1 to 2 of 2

Thread: Injecting as Property Vs Injecting as Constructor Arguments

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •