title: When to set proxyBeanMethods to false in Springs @Configuration?
body: <p>When looking at springs autoconfigure <a href="https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure" rel="noreferrer">source code</a> it seems that every auto-configuration class sets <code>proxyBeanMethods = false</code>.</p>
  
  <pre><code>@Configuration(proxyBeanMethods=false)
  public class SomeAutoConfiguration {
      ...
  }
  </code></pre>
  
  <p>The javadoc gives a detailed explanation for this particular field:</p>
  
  <blockquote>
    <p><em>Specify whether {@code @Bean} methods should get proxied in order to enforce
         bean lifecycle behavior, e.g. to return shared singleton bean instances even
         in case of direct {@code @Bean} method calls in user code. (...)</em>
    <em>If this is not needed since each of this particular configuration's {@code @Bean}
         methods is self-contained and designed as a plain factory method for container use,
         switch this flag to {@code false} in order to avoid CGLIB subclass processing.(...)</em></p>
  </blockquote>
  
  <p>After reading this I'm still confused when it is better setting it to false.</p>
  
  <p>Here are my questions:</p>
  
  <ul>
  <li>Can someone give a concrete example when this field should be true and explain why?</li>
  <li>Why is this field set to false on the auto-configuration classes?</li>
  </ul>
  
  <p><strong>Update:</strong>
   Found two issues on github that give some explanation why it is <code>false</code> on most auto-configutation classes:</p>
  
  <ul>
  <li><a href="https://github.com/spring-projects/spring-boot/issues/9068" rel="noreferrer">https://github.com/spring-projects/spring-boot/issues/9068</a></li>
  <li><a href="https://github.com/spring-projects/spring-framework/issues/22461" rel="noreferrer">https://github.com/spring-projects/spring-framework/issues/22461</a> </li>
  </ul>