title: @Bean (autowire = Autowire.BY_NAME)
body: <p>What is the purpose of setting the autowire property of <strong>@Bean</strong> to <strong>*Autowire.BY_NAME*</strong></p>
  
  <p>Looking at the JavDocs, I dont really know when I would use this, or why it would be set to <strong>*Autowire.BY_NAME*</strong></p>
  
  <pre><code>/**
   * Are dependencies to be injected via autowiring?
   */
  Autowire autowire() default Autowire.NO;
  </code></pre>
  
  <p>I have an existing prototype bean that is created with</p>
  
  <pre><code>@Bean (autowire = Autowire.BY_NAME)
  </code></pre>
  
  <p>But I dont understand why.
  The comments only state:</p>
  
  <blockquote>
    <p>Note: We have to explicitly set Autowire.BY_NAME in the bean
    definitions to be able to use @Autowired in other spring config
    classes</p>
  </blockquote>
  
  <p>Does this mean we have to set a bean to @Bean (autowire = Autowire.BY_NAME) in order to be able to use the Bean with @Autowired and it will be autowired by name from the @Bean?</p>