title: Spring IoC: Reasons to have null checks with constructor autowiring
body: <p>What are the reasons to use null checks in spring autowring?</p>
  
  <p>For instance, I often see code like this:</p>
  
  <pre><code>@Component
  public class MyComponent {
      private final MyService myService;
  
      @Autowired
      public MyComponent(MyService myService) {
          Assert.notNull(myService, "myService must not be null");
          this.myService = myService;
      }
  }
  </code></pre>
  
  <p>What is the point of <code>Assert.notNull()</code> call here?</p>
  
  <p>If I forget to declare <code>MyService</code> as a Bean Spring will fail with:</p>
  
  <blockquote>
    <p>NoSuchBeanDefinitionException: No qualifying bean of type 'com.company.MyService' available: expected at least 1 bean which qualifies as autowire candidate.</p>
  </blockquote>
  
  <p>Of course there are some corner cases in which under certain specific conditions it is possible to autowire null bean. But how important are these cases in real well designed code?</p>