spring-cloud-config icon indicating copy to clipboard operation
spring-cloud-config copied to clipboard

@ConfigurationProperties with or without @RefreshScope

Open sanderino666 opened this issue 8 years ago • 1 comments

Hi guys,

Quick question, we are using Spring Cloud Config Server and Client (of course, because it is really cool stuff ;-)) and we have a lot of classes annotated with @ConfigurationProperties. For example:

@RefreshScope
@Component
@ConfigurationProperties(prefix = "myproject.cache")
public class CacheProperties {

  private int timeout = 300;

  public int getTimeout() {
    return timeout;
  }

  public void setTimeout(int timeout) {
    this.timeout = timeout;
  }
}

In https://github.com/spring-cloud/spring-cloud-config/issues/504 @spencergibb stated:

Remove @RefreshScope from Config since @ConfigurationProperties classes are already refreshed.

We've read https://cloud.spring.io/spring-cloud-static/docs/1.0.x/spring-cloud.html#_environment_changes but it's not clear to us if can we remove the @RefreshScope annotation and still have a working properties class which refreshes after /refresh is called.

Could you clarify this? Thanks in advance!

sanderino666 avatar Jan 05 '18 18:01 sanderino666

Please read https://gist.github.com/dsyer/a43fe5f74427b371519af68c5c4904c7

spencergibb avatar Jan 05 '18 19:01 spencergibb