Closed hxm2234098193 closed 8 months ago
springboot and springcloudalibaba 's version
nacos version : 2.1.2
After I changed application.yml to bootstrap.yml, the function became normal!
you can refer https://sca.aliyun.com/zh-cn/docs/2022.0.0.0/user-guide/nacos/advanced-guide#nacos-%E9%85%8D%E7%BD%AE%E4%B8%AD%E5%BF%83%E8%BF%9B%E9%98%B6%E6%8C%87%E5%8D%97
https://github.com/alibaba/spring-cloud-alibaba/blob/2022.x/spring-cloud-alibaba-examples/nacos-example/nacos-config-example/src/main/resources/application.yaml 我看到 - nacos:nacos-config-example.properties?refresh=true,我这样配置 - optional:nacos:${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}?refresh=true测试是可以的
I use @RefreshScope in nacos but cannot refresh the remote configuration file. I wrote a controller and used the @Value annotation to inject the test.token property in the configuration file.When I start the springboot project, I can get the test.token attribute value when I access the api. But when I modified the nacos configuration file, the results of my access to the API again were not updated.
This is the controller I wrote:
This is the configuration file for test.token on the nacos server:
This is the result of accessing the API in the browser:
But when I modified the configuration file in the nacos service and accessed the API again, the attribute value of test.token did not change, and there was no real-time refresh effect.
The configuration file after modifying test.token on the nacos server:
This is the result of accessing the API in the browser (not change):
This is the configuration file of springboot: