title: @RefreshScope in Configuration class
body: <p>I have a spring boot application. I am using Spring Cloud Config to externalize properties - through Git. Everything works fine.
  I would like the beans to be refreshed when I issue the actuator refresh endpoint. Beans are refreshed eagerly as expected by doing the following:</p>
  
  <pre><code>@EventListener
  public void onRefreshScopeRefreshed(final RefreshScopeRefreshedEvent event) {
      logger.info("Received Refresh event. Refreshing all beans...");
      for (String beanName : applicationContext.getBeanDefinitionNames()) {
          Class&lt;?&gt; beanClass = applicationContext.getBean(beanName).getClass();
          if(beanClass.getName().contains("SpringCGLIB")) {
              logger.info("Proxied bean: bean name: " + beanName + " - Bean class: " + applicationContext.getBean(beanName).getClass());
          } else {
              logger.info("Regular Bean: Bean name: " + beanName + " - Bean class: " + applicationContext.getBean(beanName).getClass());
          }
          applicationContext.getBean(beanName).getClass(); // to cause refresh eagerly
      }
  }
  </code></pre>
  
  <p>The only thing not working as expected is when I annotate a Configuration class with @refreshScope (meaning at the class level), beans declared in this class are not refreshed if they don't have themselves @RefreshScope in the bean declaration.</p>
  
  <p>Here the bean is not refreshed:</p>
  
  <pre><code>@Configuration
  @RefreshScope
  public class DraftsClientConfiguration {
  
      @Bean
      MyBean aBean() {
          return new MyBean();
      }
  }
  </code></pre>
  
  <p>Here is the log from my RefreshListener class:
  We can see that in this case, there is only one bean that is not proxied.</p>
  
  <pre><code>RefreshListener - Regular Bean: Bean name: draftsServiceClient - Bean class: class com.citi.qi.athena.drafts.DraftsServiceClient
  </code></pre>
  
  <p>But here the bean is refreshed:</p>
  
  <pre><code>@Configuration
  public class DraftsClientConfiguration {
  
      @RefreshScope
      @Bean
      MyBean aBean() {
          return new MyBean();
      }
  }
  </code></pre>
  
  <p>In this second case, we have two beans (should it be the case?), one proxied and one not proxied.</p>
  
  <pre><code>RefreshListener - Regular Bean: Bean name: scopedTarget.draftsServiceClient - Bean class: class com.citi.qi.athena.drafts.DraftsServiceClient
  RefreshListener - Proxied bean: bean name: draftsServiceClient - Bean class: class com.citi.qi.athena.drafts.DraftsServiceClient$$EnhancerBySpringCGLIB$$bbfd1caf
  </code></pre>
  
  <p>According to Spring doc, beans should be refreshed by annotating @RefreshScope at the configuration class level. There is no need to specify @RefreshScope for every bean declaration of the configuration class. Am I missing something?</p>
  
  <p>By the way, I am checking if the bean is refreshed or not by putting a breakpoint in the bean declaration.</p>
  
  <p>Second question: I guess I should have only one proxied bean and not two beans as we can see in the second case?</p>