-
Jul 22nd, 2009, 03:50 AM
#1
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
-
Jul 22nd, 2009, 03:57 AM
#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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules