Why Avoid @Autowired Field Injection
Cannot detect null pointer exception when using
@Autowired
. Null pointer exception will happen if we call the actual component in runtime.Using Field injection allows circular dependency where B injects in A and A injects in B. This is code smell. Constructor injection doesn't allow this and this is not recommended by the spring team
Code smell detection. Using constructor injection we need to write it out so we know when we have too many dependencies in a class