Spring Cloud config refreshed values are not updating with @value annotation

Viewed 233

I have a spring boot project with cloud config server.I have enabled cloud bus with kafka and added required actuator endpoints to live reload properties on both server and client.

cloud: 
 bus:
  enabled: true
management:
  endpoints:
    web:
      exposure:
        include: refresh, bus-refresh, beans, env

Issue is when I am using @value annotation to read property value. I am not getting updating value. (@value only get updated when I apply @RefreshScope,But I cannot use it because I have ton of client services and will to add @RefreshScope on all beans where properties are being used)

@Value("${message.testValue}")
private String info;

private String readValue() {
    return  info;
}

But when I read using Environment, I am getting updated value after refresh

private String readValue() {
    return this.environment.getProperty("message.testValue");
}

What changes I need to implement to get updated value using @Value annotation withou @RefreshScope? Or there is something which I am missing in implementation.

0 Answers
Related