title: Refresh Spring prototype bean properties with Spring Cloud Config refresh
body: <p>I have a prototype Bean that I want its properties (annotated with <code>@Value</code>) to be refreshed when the Spring Cloud Config /refresh endpoint is triggered. </p>
  
  <p>Do prototype Beans get their external config properties refreshed automatically? Or do they still need to marked with <code>@RefreshScope</code> so they live in the 'refresh' scope cache and be invalidated like any other bean?</p>
  
  <p>BACKGROUND:</p>
  
  <p>I've been using the <code>@RefreshScope</code> on other, singleton Beans just fine and had attempted to put the annotation on a prototype Bean but that's caused problems for some existing code and unit tests as they instantiate the bean via <code>appContext.getBean("beanName", constructorArgs)</code> and cast the returned object as the expected bean type. But with <code>@RefreshScope</code> it adds a proxy in the mix which causes a <code>ClassCastException</code> for this existing code. I've tried working around that by adding an interface but that's led to more trouble within the unit test where it calls methods directly in the bean which it probably shouldn't and I was hoping to not pull those methods into the interface.</p>
  
  <p>But then it dawned on me that maybe prototype beans automatically get their properties refreshed via Spring Cloud Config on any use of them since they are instantiated every time. </p>
  
  <p>I've read thru the Spring Cloud doc and searched here but couldn't find anything specifically calling out prototype beans in this manner. So maybe its wishful thinking.</p>