You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot-Cloud:/actuator/refresh生效但无法动态获取变更值

Troubleshooting Config Refresh Issue in Spring Boot 2.0.0 + Spring Cloud Finchley.M8

Hey there, let's walk through fixing your dynamic config refresh problem. I've tackled similar issues with these exact Spring versions before, so here are the critical checks and fixes you need to apply:

1. Don't Forget the @RefreshScope Annotation

This is the most common mistake when config refresh doesn't work. Any component or configuration class that uses properties you want to refresh must be annotated with @RefreshScope.

For example, if you're using @ConfigurationProperties:

@RefreshScope
@ConfigurationProperties(prefix = "your.app.config")
public class AppConfigProperties {
    private String sampleProperty;
    
    // Getters and setters
}

Or if you're using @Value in a service/component:

@RefreshScope
@Component
public class YourBusinessService {
    @Value("${your.app.feature.enabled}")
    private boolean featureEnabled;
    
    // Service methods
}

Without this annotation, Spring won't track changes to these properties or refresh them when the /actuator/refresh endpoint is called.

2. Verify Dependencies Are Correct

Make sure your project includes the required starters for config client and actuator. For Maven, add these to your pom.xml:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Double-check that the versions align with Finchley.M8 (they should automatically if you're using the Spring Cloud BOM).

3. Clean Up Your Bootstrap Config

Your bootstrap.properties has a couple of deprecated settings and missing checks:

  • management.security.enabled=false is deprecated in Spring Boot 2.x. Instead, ensure refresh endpoint is enabled with management.endpoint.refresh.enabled=true (though management.endpoints.web.exposure.include=* should cover this, it's good to explicitly set it).
  • Confirm spring.cloud.config.uri is pointing to your running config server, and that the config server is returning the updated properties when queried directly.
  • Add spring.cloud.config.refresh.enabled=true (default is true, but explicit setting avoids any implicit issues).

Updated bootstrap.properties example:

spring.application.name=XXXXX
spring.cloud.config.uri=http://localhost:8888
management.endpoints.web.exposure.include=*
management.endpoint.refresh.enabled=true
endpoints.actuator.enabled=true

4. Ensure You're Calling the Right Endpoint Correctly

  • The POST request must be sent to your client service's /actuator/refresh endpoint, not the config server.
  • Include a Content-Type: application/json header in the request (even if the body is empty). Test with curl to rule out client-side issues:
curl -X POST http://localhost:<your-client-port>/actuator/refresh -H "Content-Type: application/json"

After sending the request, check the client service logs for lines like Refreshing beans in scope 'refresh'—this confirms the refresh was triggered.

5. Consider Upgrading to Stable Versions

Finchley.M8 is a milestone release, which can have unresolved bugs. Upgrade to the stable Finchley.RELEASE (compatible with Spring Boot 2.0.9.RELEASE) to eliminate version-specific issues. This is often a quick fix for odd behavior in pre-release versions.

Final Checks

After applying these fixes, restart your client service once, then update the config in your config server, send the POST request to /actuator/refresh, and verify if the properties are updated. Check the client service logs for any errors related to config loading or refresh—this can point you to hidden issues like permission problems or config server connectivity.

内容的提问来源于stack exchange,提问作者Prudvinath

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:47:14