Results 1 to 1 of 1
-
How to use Setter Injection and Constructor Injection
Setter Injection:
After instantiating you’re Bean with no-argument constructor or no argument static factory method setter methods on bean can be invoked.
Constructor Injection:Java Code:public class Sample { // the sample has a dependency on the item private Item item; // a setter method so that the Spring container can 'inject' a item public void setMoveFinder(Item item) { this.item = item; } }
The following code is the example of the Constructor Injection.
Java Code:public class Sample { // the sample has a dependency on the item private Item item; // a setter method so that the Spring container can 'inject' a item public Sample(Item item) { this.item = item; } }
Similar Threads
-
How to set the property of Bean by constructor injection
By Java Tip in forum Spring FrameworkReplies: 1Last Post: 05-05-2008, 09:01 AM -
How to decide whether to use Setter injection or constructor injection in your code
By Java Tip in forum Java TipReplies: 0Last Post: 03-29-2008, 12:38 PM -
How to set the property of Bean by constructor injection
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:18 PM -
How to decide whether to use Setter injection or constructor injection in your code
By JavaBean in forum Java TipReplies: 0Last Post: 09-26-2007, 08:29 PM -
How to use Setter injection and constructor injection
By JavaBean in forum Java TipReplies: 0Last Post: 09-26-2007, 08:28 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks