I have a question for you guys. The micro-service need to refresh properties attributes at the Runtime environment.
Project info:
Config client: Spring boot v2.7.3 (Spring cloud version - 2021.0.3), Java 18
Config server: Spring boot v2.7.3 (Spring cloud version - 2021.0.3), Java 18
My issue:
Config server changed value of property and call actuator refresh endpoint. But the value annotation doesn't refresh value.
PS: I try RefreshScope annotation. but it doesn't work!
Example code:
@RestController
@RequestMapping("/test")
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public class TestController {
@Autowired
private TestService testService;
@Autowired
private ContextRefresher refresher;
@Value("${test.test.second}")
private boolean serviceEnabled;
@GetMapping
public String hasPermission() {
return serviceEnabled ? "YES" : "NO";
}
@GetMapping("/test")
public Set<String> test() {
System.out.println(serviceEnabled);
return refresher.refreshEnvironment();
}
}
I need to change a variable value of "serviceEnabled".