what is difference between constructor and setter injection and which is better?
Difference between Constructor and Setter Injection
With constructor injection, you inject a property or object into the init() method of the object. With setter injection, you create a method called set%ObjectName%() which allows that object to be injected after initialization.
I prefer constructor as it provide a clear definition of the requirements of an object. Setter injection violates that by adding an undocumented requirement that if you want the object to work you also have to inject it with one or more objects immediately after construction. It also confuses the API of the object by adding public methods
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.