Spring Cloud Consul /refresh 端点缺失
Spring Cloud Consul /refresh endpoint missing
我正在使用 Spring Cloud Consul 与 Consul 进行分布式配置,一切正常。当前所有配置都在应用程序启动时从 Consul 服务器成功读取。但是当 Consul 上的某些数据发生更改时,我无法为我的应用程序重新加载此配置,因为没有 /refresh
端点。但是 here 说 "Sending a HTTP POST to /refresh will cause the configuration to be reloaded." 据我了解它应该像 Spring Cloud Config Client 但事实并非如此。我错过了什么?
您需要包含 spring 引导执行器
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
或在您的 bean 上添加 @RefreshScope
,例如
@Component
@RefreshScope
public class MyConsulConfig {
@Value("${consul.base.url}")
private String baseUrl;
}
我正在使用 Spring Cloud Consul 与 Consul 进行分布式配置,一切正常。当前所有配置都在应用程序启动时从 Consul 服务器成功读取。但是当 Consul 上的某些数据发生更改时,我无法为我的应用程序重新加载此配置,因为没有 /refresh
端点。但是 here 说 "Sending a HTTP POST to /refresh will cause the configuration to be reloaded." 据我了解它应该像 Spring Cloud Config Client 但事实并非如此。我错过了什么?
您需要包含 spring 引导执行器
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
或在您的 bean 上添加 @RefreshScope
,例如
@Component
@RefreshScope
public class MyConsulConfig {
@Value("${consul.base.url}")
private String baseUrl;
}