title: What is the order of Spring Boot bean creation and dependency injection?
body: <p>I was working on a project on Spring Boot 1.5. It had the following type of configuration class:</p>
  
  <pre><code>@Configurtion
  public class Foo{
  
   @Autowired
   private DependencyA dependencyA;
  
   @Bean
   public DependencyA getDependency(){
     return new DependencyAImpl();
    }
  
  }
  </code></pre>
  
  <p>This worked okay in Spring Boot 1.5, but when I upgraded to Spring Boot 2, this no longer worked, the application would not start up with the exception 'No bean of type DependencyA found'. I figured that this might be because the bean wasn't created when Spring tried to inject the dependency, and so, as a 'hack', added @Lazy to the dependencyA injection. This worked.</p>
  
  <p>In light of this, what is the order of execution of a configuration class. Is it:
  A) First create beans and then inject dependencies 
  B) Try to create instance with all dependencies, and then create any beans in configuration.</p>