fabio19933
fabio19933

Reputation: 124

@refreshScope Spring cloud config doesn't refresh application.properties value

I tried to use the annotation @RefreshScope on my rest controller:

@RestController
@RefreshScope
public class SpringCloudControllerTest {

@Value("${data}")
private String value;

@GetMapping
public ResponseEntity<String> testPropertiesFile(){
    return ResponseEntity.ok(value);
}

the @Value annotation refers the application.properties on my remote repository:

management.endpoints.web.exposure.include=*
data=2

if i change my file in this way:

 management.endpoints.web.exposure.include=*
 data=3

and run the request on my client side http://localhost:8081/actuator/refresh the response is just:

 [
 "config.client.version"
 ]

I don't see any response about my changes and if i run the request

 localhost:8081 

the response is always "2"

these are my dependency on client side:

compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-config', version: '2.2.6.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version:'2.3.7.RELEASE'

thank you all

Upvotes: 0

Views: 1446

Answers (1)

fabio19933
fabio19933

Reputation: 124

Solved.

I change my application name file (client side) from application.yml to bootstrap.yml

Now when i run localhost:8081/actuator/refresh i have got this response

[
"config.client.version",
"data",
"spring.cloud.bootstrap.enabled"
]

thank you all

Upvotes: 2

Related Questions