Why Avoid @Autowired Field Injection

  1. Cannot detect null pointer exception when using @Autowired. Null pointer exception will happen if we call the actual component in runtime.

  2. 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

  3. Code smell detection. Using constructor injection we need to write it out so we know when we have too many dependencies in a class