1.

Which DI would you suggest Constructor-based or setter-based DI?

Answer»

Since you can mix both, Constructor- and Setter-based DI, it is a good rule of thumb to use constructor arguments for mandatory dependencies and setters for optional dependencies. Note that the use of a Required annotation on a setter can be used to make setters required dependencies.



Discussion

No Comment Found