当我从我的属性存储库中更改一个值并重新启动 Spring Cloud Config Server 时,这些更改不会反映在它的使用者身上。
我的微服务/application.properties:
spring.application.name=my-service
spring.cloud.config.uri=http://localhost:8888
我的服务控制器.java
@RestController
public class MyServiceController {
@Autowired
private Configuration configuration;
@GetMapping("/my-service")
public MyServiceBean retrieveMyServiceProperties() {
// show propertie's values
return new MyServiceBean(configuration.getPropertie1(), configuration.getPropertie2());
}
}
spring-cloud-config-server/application.properties
server.port=8888
spring.application.name=spring-cloud-config-server
spring.cloud.config.server.git.uri=file://path
Git 仓库
我的服务.properties
my-service.propertie1=1
my-service.propertie2=2
当我向localhost:8080/my-service发送 GET 请求时,这就是我得到的结果:
{
"propertie1":1,
"propertie2":2
}
好吧,没关系!但是,如果我更改my-service.properties并重新启动 Spring Cloud Config Server,这些更改不会反映MyServiceController. 我确实需要重新启动my-microservice应用程序,以使更改生效。这是正常行为吗?我的意思是,如果这是远程的,那么应该配置是否缓存。
POPMUISE
相关分类