As I know, field injection
is not recommended. Should use constructor
instead.
What I\'m trying to do here is using @Autowired
in
Don't use field injection, use constructor injection calling back to super constructors as appropriate.
Constructor injection ensures your object is properly populated before instantiation, setter injection does not and makes code more bug prone (not another nullpointer bug....)
If you are concerned about the extra code you have to write then use Project Lombok to let Lombok generate the constructor code for you as described here Why field injection is evil
By the way as of Spring 4 if you only have a single constructor in your class you don't need @Autowired on the constructor.