下面是 spring-boot 应用程序的 application.properties
spring.application.name=test-service
server.port=8080
management.port=8081
management.context-path=/admin
spring.cloud.config.uri=http://localhost:8888
endpoints.refresh.enabled=true
endpoints.restart.enabled=true
当我启动应用程序时,它会联系配置服务器并按预期加载属性。
我修改配置服务器上的属性并使用触发应用程序刷新
curl -X POST http://localhost:8081/admin/refresh
API 打印已更改的属性的名称。
当我在该物业上进行获取时,我仍然看到旧值
curl -X GET http://localhost:8081/admin/env/{property_name}
我触发了重新启动,它会获取新的属性值
curl -X POST http://localhost:8081/admin/restart
当我尝试使用更改属性值时看到相同的行为
curl -X POST http://localhost:8081/admin/env -d property1=123
当我尝试获取属性值时,我仍然看到旧值
curl -X GET http://localhost:8081/admin/env/property1
当我将 management.port 更改为 8080(与 server.port 相同)时,一切都按预期工作。
这种行为是预期的吗?在我看来,它正在修改 2 个不同的环境,一个用于运行在 8080 上的服务器,另一个用于运行在 8081 上的服务器。